syntax

This is a discussion on syntax within the Linux Programming forums, part of the Platform Specific Boards category; What are the major differences of the linux syntax in comparision to windows syntax while programming?...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    26

    syntax

    What are the major differences of the linux syntax in comparision to windows syntax while programming?

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    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

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    26
    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.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,849
    > 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

    Code:
    #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

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    26
    Thanks for the advice. That is what I have been needing!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 09:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21