[gambit-list] #ifdef equivalent in Scheme?

Ralph Möritz ralph.moeritz at outlook.com
Wed Apr 17 06:21:51 EDT 2013


> It may seem like a hack, but the most reliable way to detect different filesystems is to check the path separator character, which is \ on Windows and / on Unix:
>
> (define windows?
> (char=? #\\ (let ((cd (current-directory))) (string-ref cd (- (string-length cd) 1)))))
>
> In Gambit, directories are guaranteed to end with the path separator character.
>
> You could also use functions that are specific to Windows:
>
> (define windows?
> (string=? (path-volume "c:") "c:"))
>
> Who can come up with other ways? :-)

Well, I suppose I could also split the OS-specific definitions into separate .scm files & change the compilation process accordingly. (Currently a shell script for which I've written a DOS batch file equivalent. I may replace this with a makefile at some point) 		 	   		  


More information about the Gambit-list mailing list