Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

__cplusplus

46 views
Skip to first unread message

Bonita Montero

unread,
Nov 26, 2019, 10:53:57 AM11/26/19
to
Can anyone here tell me whether I have to enable the standard
macro __cplusplus to report the correct value with VC++ through
the /Zc:__cplusplus option of the compiler. If I don't the compiler
statically reports 199711L.

guinne...@gmail.com

unread,
Nov 26, 2019, 11:29:33 AM11/26/19
to

Barry Schwarz

unread,
Nov 26, 2019, 6:23:48 PM11/26/19
to
Wouldn't that depend on which compiler you are using?

--
Remove del for email

Öö Tiib

unread,
Nov 26, 2019, 7:05:01 PM11/26/19
to
OP seemed to claim using VC++. Everybody who accepts VC++ as one of
target compilers for their code will anyway check presence and value
of _MSC_VER in it since there is always some microsoft-specific
weirdness to work around regardless if that /Zc:__cplusplus was set
as compiler option or forgotten to.



woodb...@gmail.com

unread,
Nov 26, 2019, 9:15:53 PM11/26/19
to
I have Microsoft and Linux warts to work around. Please, Microsoft,
get rid of WSAStartup and please, Linux, put sctp.h in a better
place:
https://github.com/Ebenezer-group/onwards/blob/master/src/cmw/tiers/cmwA.cc

The bulk of my code is closed source and doesn't run on
Windows or Linux. It runs on FreeBSD. Thankfully I don't have
warts due to FreeBSD.


Brian
Ebenezer Enterprises - In G-d we trust.
https://github.com/Ebenezer-group/onwards

Bonita Montero

unread,
Nov 26, 2019, 11:45:40 PM11/26/19
to
> OP seemed to claim using VC++. Everybody who accepts VC++ as one of
> target compilers for their code will anyway check presence and value
> of _MSC_VER in it since there is always some microsoft-specific
> weirdness to work around regardless if that /Zc:__cplusplus was set
> as compiler option or forgotten to.

_MSC_VER wouldn't be a replacement for __cplusplus when you want to
be portable.

Bonita Montero

unread,
Nov 26, 2019, 11:50:04 PM11/26/19
to
> I have Microsoft and Linux warts to work around. Please, Microsoft,
> get rid of WSAStartup and please, Linux, put sctp.h in a better
> place:
> https://github.com/Ebenezer-group/onwards/blob/master/src/cmw/tiers/cmwA.cc

Where's the problem? Use a C++ socket-lib because there are a
lot of differences between BSD-sockets and Windows sockets:
https://www.apriorit.com/dev-blog/221-crossplatform-linux-windows-sockets

Öö Tiib

unread,
Nov 27, 2019, 12:53:50 AM11/27/19
to
Did I say anything will replace anything? All useful portable C++ code
keeps having growing pile of preprocessor checks of various macros in
one or other place forever.

Bonita Montero

unread,
Nov 27, 2019, 1:18:42 AM11/27/19
to
>>> OP seemed to claim using VC++. Everybody who accepts VC++ as one of
>>> target compilers for their code will anyway check presence and value
>>> of _MSC_VER in it since there is always some microsoft-specific
>>> weirdness to work around regardless if that /Zc:__cplusplus was set
>>> as compiler option or forgotten to.

>> _MSC_VER wouldn't be a replacement for __cplusplus when you want to
>> be portable.

> Did I say anything will replace anything? ...

1. The discussion-context was __cplusplus
2. If you don't care for portability, checking _MSC_VER
could be a replacement for __cplusplus-checking.

Öö Tiib

unread,
Nov 27, 2019, 2:00:58 AM11/27/19
to
On Wednesday, 27 November 2019 08:18:42 UTC+2, Bonita Montero wrote:
> >>> OP seemed to claim using VC++. Everybody who accepts VC++ as one of
> >>> target compilers for their code will anyway check presence and value
> >>> of _MSC_VER in it since there is always some microsoft-specific
> >>> weirdness to work around regardless if that /Zc:__cplusplus was set
> >>> as compiler option or forgotten to.
>
> >> _MSC_VER wouldn't be a replacement for __cplusplus when you want to
> >> be portable.
>
> > Did I say anything will replace anything? ...
>
> 1. The discussion-context was __cplusplus

So what? It is standardized but non-portable in practice.

> 2. If you don't care for portability, checking _MSC_VER
> could be a replacement for __cplusplus-checking.

Nonsense, it would be utterly useless check in majority of
non-portable C++ code that I've seen.

Bonita Montero

unread,
Nov 27, 2019, 2:11:10 AM11/27/19
to
>> 1. The discussion-context was __cplusplus

> So what? It is standardized but non-portable in practice.

If you set the MSVC compiler-settings appropriately MSVC conforms.
And the other compilers are conformant anyway. So there's a way
to use __cplusplus across all compilers.

>> 2. If you don't care for portability, checking _MSC_VER
>> could be a replacement for __cplusplus-checking.

> Nonsense, it would be utterly useless check in majority of
> non-portable C++ code that I've seen.

I said that it wouldn't be portbale. But if you're fixed to MSVC you
could replace __cplusplus-checks with _MSC_VER-checks to different
values.
0 new messages