CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: __cplusplus number

    The only problem I found in a more complex project is that one of its libs uses an internal variable called ssize_t which it defines like this:-

    Code:
    #ifdef _MSC_VER
    typedef SSIZE_T ssize_t;
    #endif
    This doesn't compile any more - so what is / was SSIZE_T? Is it something which used to be supported in MSVC but which has been dropped now
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  2. #17
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: __cplusplus number

    Quote Originally Posted by John E View Post
    The only problem I found in a more complex project is that one of its libs uses an internal variable called ssize_t which it defines like this:-

    Code:
    #ifdef _MSC_VER
    typedef SSIZE_T ssize_t;
    #endif
    This doesn't compile any more - so what is / was SSIZE_T? Is it something which used to be supported in MSVC but which has been dropped now
    From MSDN:
    SSIZE_T
    A signed version of SIZE_T.

    This type is declared in BaseTsd.h as follows:

    typedef LONG_PTR SSIZE_T;
    Victor Nijegorodov

  3. #18
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: __cplusplus number

    Quote Originally Posted by VictorN View Post
    From MSDN:

    SSIZE_T
    A signed version of SIZE_T.

    This type is declared in BaseTsd.h as follows:

    typedef LONG_PTR SSIZE_T;
    How strange... it does seem to be there so I'll need to figure out why it's not getting found any more
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  4. #19
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: __cplusplus number

    ssize_t as of C++20 is now a c++ type. It is a signed version of size_t. So if you are compiling as C++20 then you can't now define ssize_t as a type.

    So I guess you need something like:

    Code:
    #if (defined(_MSC_VER) && defined(__cplusplus) && (__cplusplus < 201704L))
        typedef SSIZE_T ssize_t;
    #endif
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  5. #20
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: __cplusplus number

    Thanks 2kaud. In my case, __cplusplus is showing up as 210402 so I'm a bit baffled at the moment.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  6. #21
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: __cplusplus number

    Quote Originally Posted by 2kaud View Post
    ssize_t as of C++20 is now a c++ type.
    A quick question... if ssize_t was now a C++ type, should it show in the same colour as types like int / void etc? In my case int and void both show in a bright blue colour whereas ssize_t is a much paler colour (almost a pale shade of turquoise)
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  7. #22
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: __cplusplus number

    It is because ssize_t is typedef:
    Code:
    typedef LONG_PTR SSIZE_T;
    However you can change thi color in Tools/Options/Font and colors/C++ User types
    Last edited by VictorN; May 6th, 2021 at 03:34 AM.
    Victor Nijegorodov

  8. #23
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: __cplusplus number

    You just beat me to it Victor! The good news is that /Zc:__cplusplus doesn't seem to be connected to the problem. basetsd.h defines SSIZE_T like this:-

    Code:
    typedef LONG_PTR SSIZE_T, *PSSIZE_T;
    So if I change my library code locally to look like this, the compilation works again:-

    Code:
    #ifdef _MSC_VER
    typedef LONG_PTR ssize_t;
    #endif
    So all I can think is that there's an MSVC header file somewhere which used to #include basetsd.h but which isn't #including it any more. It's quite rare for Microsoft to do things like that but it's the only thing that makes sense to me. My local library code definitely hasn't changed.
    Last edited by John E; May 6th, 2021 at 03:40 AM.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

Page 2 of 2 FirstFirst 12

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