[Scons-users] How to check if the C++ compiler supports `override`?
Carsten Fuchs
carsten.fuchs at cafu.de
Tue Aug 5 11:56:44 EDT 2014
Hi Mark,
Am 04.08.2014 um 22:36 schrieb Mark A. Flacy:
> http://www.scons.org/doc/production/HTML/scons-user.html#idp24303632
>
> Pretty much the same way that autoconf would; try a test compile to see.
This works like a charm, many thanks for your quick reply! :-)
Best regards,
Carsten
PS: Just for reference, here is the code that I use:
> envCommon = Environment()
>
> # [...]
> elif sys.platform=="linux2":
> def CheckOverrideIdentifier(context):
> source = """
> class A
> {
> public:
>
> virtual int f() const { return 1; }
> }
>
> class B : public A
> {
> public:
>
> int f() const override { return 2; }
> }
>
> int main()
> {
> return 0;
> }
> """
>
> context.Message('Checking for C++11 `override` identifier...')
> result = context.TryLink(source, '.cpp')
> context.Result(result)
> return result
>
> envCommon.Append(CCFLAGS = ["-std=c++0x"]) # CCFLAGS is also
taken as the default value for CXXFLAGS.
>
> conf = Configure(envCommon, custom_tests = {'CheckOverrideIdentifier' : CheckOverrideIdentifier})
>
> if not conf.CheckOverrideIdentifier():
> print "C++11 `override` identifier is not supported (defining an empty macro as a work-around)."
> conf.env.Append(CPPDEFINES = [("override", "")])
>
> envCommon = conf.Finish()
>
> # [...]
More information about the Scons-users
mailing list