-
May 5th, 2021, 08:06 AM
#16
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
-
May 5th, 2021, 09:23 AM
#17
Re: __cplusplus number
Originally Posted by John E
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
-
May 5th, 2021, 10:51 AM
#18
Re: __cplusplus number
Originally Posted by VictorN
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
-
May 5th, 2021, 11:29 AM
#19
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)
-
May 5th, 2021, 12:38 PM
#20
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
-
May 6th, 2021, 03:02 AM
#21
Re: __cplusplus number
Originally Posted by 2kaud
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
-
May 6th, 2021, 03:27 AM
#22
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
-
May 6th, 2021, 03:35 AM
#23
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|