cppstd setting has no default value
See original GitHub issueTo help us debug your issue please explain:
- I’ve read the CONTRIBUTING guide.
- I’ve specified the Conan version, operating system version and any tool that can be relevant.
- I’ve explained the steps to reproduce the error or the motivation/use case of the question/suggestion.
Hello,
First off, I would like to say thank you to everyone involved in this awesome project.
I have read the how-to article about managing the C++ standard, where it is stated that “By default Conan will detect the default standard of your compiler to not generate different binary packages.”
My conan package uses a custom build system for which I need to manually parse and pass the CXX flags. I caught the error when I tried to pass a flag for the standard with the following code:
if "gnu" in self.settings.cppstd:
cxx_flags.append("-std=gnu++%s" % str(self.settings.cppstd).replace("gnu", ""))
else:
cxx_flags.append("-std=c++%s" % str(self.settings.cppstd))
cxx_flags.append("-std=c++%s" % str(self.settings.cppstd))
TypeError: __str__ returned non-string (type NoneType)
Upon further debugging I spotted the following custom warning being outputted:
if not self.settings.cppstd:
self.output.warn("cppstd empty")
My recipe specified cppstd in the settings and I did not pass a command line argument and the settings.cppstd was None instead of a detected default value.
I ended up with the following temporary workaround in my configure
method:
if not self.settings.cppstd:
self.output.warn("cppstd empty, setting default")
from conans.client.build.cppstd_flags import cppstd_default
self.settings.cppstd = cppstd_default(self.settings.get_safe("compiler"),
self.settings.get_safe("compiler.version"))
I would assume that the default value should be set for the user as well as internally when no cppstd command line argument is given but it is specified in the recipe.
For the record, not having the cppstd specified in the recipe, (properly) throws an exception on the following line:
if not self.settings.cppstd:
ConanException: 'settings.cppstd' doesn't exist
Software information:
I’m currently using Conan version 1.2.0
on
ProductName: Mac OS X
ProductVersion: 10.13.3
BuildVersion: 17D102
with
Xcode 9.2
Build version 9C40b
and Python 3.6.4
installed from brew
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (5 by maintainers)
Awesome! Once again, a big thank you to everyone who is involved with the development of this project.
Hi @lasote, @memsharded,
Following your last two comments, I have adjusted my code not to use the
cppstd_default
function and I have adjusted the appending of the flag to the following:My question was answered and the issue can be closed as it is in fact the intended behavior. However I would suggest adding to the documentation that the cppstd has a default value of
None
.