To Find the Operating System

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saranjegan
    New Member
    • Feb 2007
    • 50

    To Find the Operating System

    hello, am in development serial port based application which should run on both POSIX and Windows based OS, at a first step i need to find the OS and then i will use relevant OS API to work with the serial port,so can any one suggest me how to find the OS running in C.
  • Firecore
    New Member
    • Jul 2007
    • 114

    #2
    Originally posted by saranjegan
    hello, am in development serial port based application which should run on both POSIX and Windows based OS, at a first step i need to find the OS and then i will use relevant OS API to work with the serial port,so can any one suggest me how to find the OS running in C.
    Serial port?

    Are those the small blue ports your monitor is connected to?

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      Originally posted by Firecore
      Serial port?

      Are those the small blue ports your monitor is connected to?
      No they are the ports that are being replaced by USB, most computers used to have 2 of them but today normally they only have 1. Generally they use the RS232 protocol and can be used for serial communication to a large number of devices.


      saranjegan presumably you aren't actually proposing to run the same image on both machines, you are just trying to build a portable program? You should find some compiler symbols that enable you to distinguish which platform you are compiling for.

      For instance the MSVC compiler defines the symbol _MSC_VER to its version number, presence of this symbol indicates use of the MSVC compiler and therefore a Windows platform as the target.

      Check you compiler documentation for the symbols it defines.

      Comment

      Working...