#Practical examples to use 'extern constexpr bool' from CMake?

22 messages · Page 1 of 1 (latest)

sacred magnet
#

I'd like to write assert in C++23 with CMake and multiple build modes as mentioned in https://learnmoderncpp.com/2020/02/10/writing-assert-in-cpp/ to use modules, meaning without preprocessor.
Do you have practical examples for that? Searching for "C++ extern constexpr" turned up no meaningful results.

chilly nimbusBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

fading igloo
#

if you want to pass information from cmake to your code, defining macros is still the most straightforward way

#

you can still do that with modules

#

the only other way I could think of is using cmake to generate the source code defining your ReleaseBuild constants or whatever

#

yes, you could do that, but why would you

#

and with modules, you can keep them private

#

nobody will be exposed to the macros just because they import your assert stuff

#

sorta 😛

#

sometimes 😛

#

Since C++ named modules left the experimental state in CMake (see import CMake; the Experiment is Over!), CMake development has continued to add more support for modules. The most recent development is the experimental support of import std;. C++23 introduced support for APIs to be available via the named module std. This means that import […]

#

still experimental support in cmake, only works on some compiler + stdlib + os combos

#

maybe @sacred magnet likes living on the bleeding edge

sacred magnet
#

I'd expect apps or libs to offer a reasonable named default module for configuring hardening etc.
However, I guess you are saying that because there is so far no standard cli for reproducing module interaction,
so using macros is simpler?!

fading igloo
#

"reasonably named default module"?
"reproducing module interaction"??

sacred magnet
fading igloo
#

when there are easier ways to affect the compilation... using compiler flags

sacred magnet
#

ok, agreed.

#

!solved

chilly nimbusBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

fading igloo