C++ Error: Underscores in Function Names

  • Context: C/C++ 
  • Thread starter Thread starter ehrenfest
  • Start date Start date
  • Tags Tags
    C++ Function
Click For Summary

Discussion Overview

The discussion revolves around a compilation error in C++ related to the use of underscores in function names. Participants explore potential reasons for the error and suggest troubleshooting steps.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant reports an error indicating that `angle_between` cannot be used as a function and notes that changing the name to "function1" resolved the issue.
  • Another participant suggests that underscores are not inherently problematic, but leading and trailing underscores may cause issues.
  • Some participants propose that there might be a typo in the function name `angle_between` that needs to be checked.
  • There is a suggestion to post the specific line of code where the compiler reports the error for further analysis.
  • One participant recommends searching through the source code for any previous definitions of `angle_between` that might conflict with its current usage.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the cause of the error, with multiple potential explanations and troubleshooting approaches being discussed.

Contextual Notes

There is uncertainty regarding the specific nature of the error and the conditions under which underscores in function names may cause issues. The discussion does not resolve these uncertainties.

ehrenfest
Messages
2,001
Reaction score
1
I got the following error when I tried to compile some code:

Code:
error: `angle_between' cannot be used as a function

I changed the function name to "function1" and it compiled. Since when did C++ not like underscores in function names?
 
Technology news on Phys.org
The underscore isn't a problem ( although leading and trailing ones can cause issues)
Are you sure you haven't got a angle_between() typo somewhere ?

Can you post the line the compiler complains about?
 
Yeah, it "looks" fine. Maybe you should post the code and where the compiler cries.
 
Grep your sources looking for angle_between, could be it was defined earlier as something else.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
12K
Replies
14
Views
4K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 0 ·
Replies
0
Views
3K
Replies
6
Views
3K