Menu

#262 version:1:1: error: expected unqualified-id

release_4.3.x
open
nobody
None
1
2022-04-18
2022-04-18
No

itpp 4.3.1 doesn't build on macOS when using a C++20-capable compiler. The error is:

version:1:1: error: expected unqualified-id

This was originally reported to MacPorts at https://trac.macports.org/ticket/64990

This problem occurs because:

  • C++20-capable compilers have a header called "version". Although you don't include this header directly, some of the system headers you do include themselves include the "version" header.
  • Mac filesystems are usually case-insensitive. #include <version> will happily use a file called "version" or "VERSION" or "VeRsIoN", etc.
  • You have a file called "VERSION" in your project's main directory.
  • You use an -I flag pointing to your project's main directory.

The recommended solution is: Don't use an -I flag pointing to your project's main directory. If there are headers in the main directory that you need to include, move them to another directory. For example, if you would by default create a config.h in the main directory, create it somewhere else.

An alternate solution is to rename the VERSION file to something else, such as VERSION.txt. Remember to update all references to the file such as in autogen.sh.

The contents of the VERSION file don't even appear to be correct. In itpp 4.3.1, I would have expected the contents of the file to be "4.3.1" but it is actually "4.3 8:2:0 git". Maybe the file no longer serves a purpose and should be deleted along with all references to it such as in autogen.sh.

I did not test the autotools build, but at least the cmake build (when doing an out-of-source build) succeeded if I simply deleted the VERSION file first.

Discussion


Log in to post a comment.