I found this question/answer which describes the use of [[deprecated]] as a C++14 feature to instruct the compiler to warn about the use of deprecated functions.
I tried using this in a simple function within a project - the warning was issued 3 times. I initially thought this might be multiple template instantiations, so I tested a simple program.
[[deprecated]] void doNothing() {}
int main(){
doNothing();
}
g++ -std=c++14 deprecatedTest.cpp outputs
deprecatedTest.cpp: In function 'int main()':
deprecatedTest.cpp:4:5: warning: 'void doNothing()' is deprecated [-Wdeprecated-declarations]
doNothing();
^
deprecatedTest.cpp:1:21: note: declared here
[[deprecated]] void doNothing() {}
^
deprecatedTest.cpp:4:5: warning: 'void doNothing()' is deprecated [-Wdeprecated-declarations]
doNothing();
^
deprecatedTest.cpp:1:21: note: declared here
[[deprecated]] void doNothing() {}
^
deprecatedTest.cpp:4:15: warning: 'void doNothing()' is deprecated [-Wdeprecated-declarations]
doNothing();
^
deprecatedTest.cpp:1:21: note: declared here
[[deprecated]] void doNothing() {}
Is the warning supposed to be printed 3 times? (To get more attention?)
This seems a strange behaviour, but I can't imagine a simpler test.