C/C++ C++ Error: Underscores in Function Names

  • Thread starter Thread starter ehrenfest
  • Start date Start date
  • Tags Tags
    C++ Function
Click For Summary
The discussion centers around a compilation error in C++ related to the function name "angle_between," which cannot be used as a function. The user resolved the issue by renaming the function to "function1," suggesting that underscores in function names should not inherently cause problems, except for leading or trailing underscores. Participants recommend checking for typos related to "angle_between" and suggest posting the specific line of code causing the error for further assistance. Additionally, they advise searching the codebase for any prior definitions of "angle_between" that might conflict with its intended use.
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.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

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