PDA

View Full Version : syntax



ghe1
02-12-2002, 02:41 PM
What are the major differences of the linux syntax in comparision to windows syntax while programming?

starX
02-12-2002, 10:36 PM
In Java, and Perl, very little.

In C, maybe nothing, maybe a lot, it depends on what you're trying to do. By an large the differences come when you use libraries that are unique to a certain operating system.

If you gave me a better idea of what you're trying to do, I can give you a more definite answer,

starX
www.axisoftime.com

ghe1
02-13-2002, 08:23 AM
My situation is this: I have a c program that determines the free disk space on a drive. Within this code, I need to add a function that is called before the rest of the code executes to determine whether or not I am in a windows environment or in a linux environment. I also have code for the unix side, "statvfs" that determines the disk space.

Salem
02-13-2002, 01:30 PM
> to determine whether or not I am in a windows environment or in a linux environment.
No such function exists

You need to compile the code with conditional compilation directives, like so



#ifdef LINUX
space = statvfs();
#elif WINDOWS
space = GetDiskFreeSpace(); // or whatever
#else
#error Not LINUX or WINDOWS
#endif


Then you compile it for LINUX using
gcc -DLINUX prog.c

and for windows
cl -DWINDOWS prog.c

ghe1
02-13-2002, 01:53 PM
Thanks for the advice. That is what I have been needing! :D