Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling example code: 5-map.cc fail #103

Open
YuxinxinChen opened this issue Oct 5, 2021 · 2 comments
Open

Compiling example code: 5-map.cc fail #103

YuxinxinChen opened this issue Oct 5, 2021 · 2 comments

Comments

@YuxinxinChen
Copy link

Hi,

This is a wonderful library I am looking for. However, when I am trying to compile the example code from the master branch, It fails with an error message:

5-map.cc:44:1: error: body of ‘constexpr’ function ‘constexpr const char* describe(Channel)’ not a return-statement
   44 | }
      | ^
make: *** [Makefile:20: 5-map.exe] Error 1

The g++ version I am using:

g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Thanks!

-Yuxin

@aantron
Copy link
Owner

aantron commented Nov 8, 2021

Thanks!

Does the example work if you remove this line from describe?

return "needed for gcc 5";

What is the command line you are using to compile the file? In particular, what language standard?

@QAbot-zh
Copy link

@aantron
I found the reason why the case failed to compile.
link
C++11's constexpr functions support exactly one return statement. The restriction was lifted in C++14.
So it doesn't work if only remove the final return line from describe in C++11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants