CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2002
    Posts
    72

    A question about #define WIN32 and "sbrk"

    Hi, everyone!

    Look at the source codes,

    --------
    /* #define WIN32 */
    #ifdef WIN32
    #define MORECORE wsbrk
    #endif
    --------

    Such is the comments,

    --------
    WIN32 (default: undefined)
    Define this on MS win (95, nt) platforms to compile in sbrk emulation.
    --------

    I have two questions,

    1. What means WIN32? When the variable "WIN32" becomes
    defined? When it is not defined?

    2. What means "sbrk" in the comment? What means "wsbrk"?

    Btw: the software is written for both Windows and Linux
    platforms.

    Cheers,
    George

  2. #2
    Join Date
    Aug 2002
    Location
    VA, USA
    Posts
    137
    George,

    WIN32 is a preprocessor definition that when defined includes
    code specific to the Windows platform. My compiler (VC6)
    defines WIN32 in the project settings/C++/preprocessor
    dialog. Other compilers will define their target platform in
    other places.

    In your case when your code is compiled with a Windows
    compiler the preprocessor will define MORECORE as wsbrk.
    Although I'm not sure what sbrk does, the "w" prefix version
    being used on the Windows platform might mean a wide-
    char version of sbrk.

    -Regrads, willchop

  3. #3
    Join Date
    Aug 2002
    Location
    VA, USA
    Posts
    137
    FYI: ReorX posted the meaning of sbrk in this cross-posted thread. See "Visual C++ Programming" forum.

    Regards, willchop
    Last edited by willchop; September 1st, 2002 at 02:00 PM.

  4. #4
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,020
    sbrk on Unix is the routine that allocates memory. This is a very low level routine and you shouldn't need to call it as it is called from new and malloc.

    As willchop said, it would help if you only posted your questions in one forum. That way several people won't be wasting their time answering questions that have already been answered.
    Succinct is verbose for terse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured