Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc TemplateClass<::GlobalSymbol> error on <::

Tags:

c++

gcc

templates

For some reason gcc does not like when template parameter is a global namespace symbol, i.e.

TemplateClass<::GlobalSymbol>

It works when I do

TemplateClass< ::GlobalSymbol>

That is, gcc does not like to see <::

Is it possible to prevent without modifying sources (which are autogenerated)?

UPD: I don't want to modify sources. I found that -fpermissive seems to change this to a warning instead of error, but haven't found yet how to enable it from code (using pragmas for example).

UPD: Well, I found that

 #pragma GCC diagnostic ignored "-fpermissive"

does the trick, anyway I accept the answer that helped me to find this out.

like image 839
queen3 Avatar asked Feb 21 '23 15:02

queen3


1 Answers

<: is a digraph which is equivalent to [, thus the error. Since you don't want to modify the code a workaround is to use -fpermissive command-line argument or pragma to G++ (it actually gives you a hint):

test.cpp:9:16: note: (if you use ‘-fpermissive’ G++ will accept your code)
like image 175
vitaut Avatar answered Mar 02 '23 00:03

vitaut