Thread: Use of #ifdef for portability - a specific case

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    98

    Use of #ifdef for portability - a specific case

    In Solaris, the protoptype of psignal() is in siginfo.h. However, under Linux and Mac OS X, the protoptype of psignal() is in signal.h; siginfo.h does not exist. Some advocate writing 2 different .c files. Let's say I do not want to do that for such a minor discrepancy. How do I write a C program that can run on all 3 operating systems, by using #ifdef for example? That is, how can I do something like:
    Code:
    #ifdef SOLARIS
    #  include <siginfo.h>
    #else
    #  include <signal.h>
    #endif
    int main ()
    { ...
       ... psignal() ...
       ...
    }
    Thanks.
    Last edited by hzmonte; 11-03-2005 at 02:46 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someone please clean up my code
    By ki113r in forum C Programming
    Replies: 10
    Last Post: 09-12-2007, 10:03 AM
  2. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 07:48 PM
  3. Printing weekday
    By sworc66 in forum C Programming
    Replies: 12
    Last Post: 09-13-2002, 07:03 AM
  4. Changing bkgrnd color of Child windows
    By cMADsc in forum Windows Programming
    Replies: 11
    Last Post: 09-10-2002, 11:21 PM
  5. rand()
    By serious in forum C Programming
    Replies: 8
    Last Post: 02-15-2002, 02:07 AM