fix compile errors when using gcc and clang#3
Open
doug-moen wants to merge 1 commit intorogrosso:masterfrom
Open
fix compile errors when using gcc and clang#3doug-moen wants to merge 1 commit intorogrosso:masterfrom
doug-moen wants to merge 1 commit intorogrosso:masterfrom
Conversation
Owner
|
Dear Doug,
I have the Ubuntu 20.04 LTS in Windows 10 and used the clang compiler 10.0.0-4. I compiled the code with
clang++ -o dmc -std=c++17 *.cpp
This command line does not produce any error. The code compiles and run. The code was developed using Visual Studio 2019 community. I set the compiler option `C++ Language Standard` to `ISO C++ 17 Standard`.
In the Ubuntu terminal I also run the compiler with the option -std=c++11. I think, it will require a bunch of work to compile the code with this standard. If it is required, I can tray to fix the syntax. Remember that the code was developed for research and at the moment these are all the compilers I can use for testing. But I like the idea of someone intending to use the software.
As soon as I have time I will start fixing the problems with the Volumes class. But I am afraid, we have much more work than just fixing the template specialization issue.
Sincerely
R.Grosso
Von: Doug Moen <notifications@github.com>
Gesendet: Sunday, August 2, 2020 1:49 AM
An: rogrosso/tmc <tmc@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
Betreff: [rogrosso/tmc] fix compile errors when using gcc and clang (#3)
When compiling using gcc or clang, Volumes.h produced 8 compile errors like this:
./Volumes.h:134:10: error: explicit specialization of 'surface' in class scope
double surface<Surface::Sphere>(const double x, const double y, const double z)
^
The problem is that the C++ standard does not permit a template to be specialized in class scope, only in namespace scope, but Microsoft Visual C++ allows this as a language extension, and gcc/clang do not.
Reference: https://stackoverflow.com/questions/3052579/explicit-specialization-in-non-namespace-scope
The fix is to move the template specializations out of the Volumes::Surface class and define them in namespace scope.
…_____
You can view, comment on, or merge this pull request online at:
#3
Commit Summary
* fix compile errors when using gcc and clang
File Changes
* M cpp_dmc/Volumes.h <https://github.com/rogrosso/tmc/pull/3/files#diff-3b16aab62dc52fb548bfed8cab510514> (164)
Patch Links:
* https://github.com/rogrosso/tmc/pull/3.patch
* https://github.com/rogrosso/tmc/pull/3.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, <#3> view it on GitHub, or <https://github.com/notifications/unsubscribe-auth/AEW4WUHP6LLIVQFBDIBWBTDR6SSV5ANCNFSM4PSEVLRQ> unsubscribe.
|
For what it is worth, I'm going to fix this issue and make it work because I would like to use your code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When compiling using gcc or clang, Volumes.h produced 8 compile errors like this:
The problem is that the C++ standard does not permit a template to be specialized in class scope, only in namespace scope, but Microsoft Visual C++ allows this as a language extension, and gcc/clang do not.
Reference: https://stackoverflow.com/questions/3052579/explicit-specialization-in-non-namespace-scope
The fix is to move the template specializations out of the
Volumes::Surfaceclass and define them in namespace scope.