Jump to content

Building on Windows using gcc - compiler vs. environment #ifdefs


Recommended Posts

I've been using SystemC for years on Linux with gcc and Windows with Visual Studio.  I decided to try it out in Eclipse on windows with the Cygwin environment.


Several problems have popped up.  For example there are #ifdefs around defining data types supported by the compiler, such as __int64 in the Microsoft compiler versus long long elsewhere.  However these are defined based on the _WIN32 predefined macro.


That's not really correct, it should be defined based on the compiler type - in this case using _MSC_VER instead of _WIN32.


Example from sc_nbdefs.cpp



// Support for the long long type. This type is not in the standard
// but is usually supported by compilers.
#if !defined(_WIN32) || defined(__MINGW32__)
const uint64 UINT64_ZERO   = 0ULL;
const uint64 UINT64_ONE    = 1ULL;
const uint64 UINT64_32ONES = 0x00000000ffffffffULL;
const uint64 UINT64_ZERO   = 0i64;
const uint64 UINT64_ONE    = 1i64;
const uint64 UINT64_32ONES = 0x00000000ffffffffi64;
Link to comment
Share on other sites

Although Cygwin is not among the most widely tested platforms for the Accellera SystemC proof-of-concept simulator, the current version 2.3.1 has been tested successfully on

  • Windows 7 SP1 (WoW64), (Cygwin 1.7.17)
    • GNU C++ compiler versions gcc-3.4.4 through gcc-4.3.4 (x86)

Please provide at least

  • SystemC version
  • platform (version), compiler (version), flags
  • compile/runtime warnings and errors

AFAIK, the _WIN32 macro tells that you're using the Windows API.  Using the Windows API implies that you have support for __int64 and the like.

Do you define _WIN32 explicitly on the command-line?  Why?  Cygwin does not provide this symbol by default.


Greetings from Oldenburg,

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...