[Live-devel] Building with C++ version less than 20

Jörg Dommaschk j.dommaschk at instar.com
Sun Aug 27 19:55:44 PDT 2023


I don't mind checking it in any different way. Alas, I don't know any. Maybe someone else does - since this is a mailing list, hundreds of smart people can see this question. Don't be shy, everyone ;)

However, I am still not sure you are checking the version in the right way. Because what you posted looks like you redefine the macro somewhere in your code. As I said, this does NOT work. The C++ version is ultimately decided by the compiler. The __cplusplus macro just informs you about what the compiler uses. Redefining it in the code is nonsensical and does not do what you think it does. If you really want to convince me, don't redefine it anywhere, just print it. If it outputs anything less than C++20 and still compiles fine even with any C++20 features, I will be seriously flabbergasted, but will accept this as an opportunity to increase my knowledge.

----- Original Message -----
From: "Ross Finlayson" <finlayson at live555.com>
To: "LIVE555 Streaming Media, development & use" <live-devel at us.live555.com>
Sent: Friday, August 25, 2023 9:23:26 PM
Subject: Re: [Live-devel] Building with C++ version less than 20

> On Aug 25, 2023, at 2:42 AM, Jörg Dommaschk via live-devel <live-devel at us.live555.com> wrote:
> 
> 
> How do you define __cplusplus on your systems, though? Because as you can see here: 
> https://en.cppreference.com/w/cpp/atomic/atomic_flag
> this test method really only exists since C++20.

Nonetheless, on the two systems that I tested (FreeBSD and Mac OS X), __cplusplus is defined as follows (respectively):

<built-in>:377:21: note: expanded from here
#define __cplusplus 201402L

and

<built-in>:393:21: note: expanded from macro '__cplusplus'
#define __cplusplus 199711L

There might be a way to accurately check whether the “test()” member function is defined for "std::atomic_flag”, but checking "__cplusplus >= 202002L” is definitely not the right way to do so.  Sorry.


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/


_______________________________________________
live-devel mailing list
live-devel at lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel



More information about the live-devel mailing list