Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Coffee corner » important note when a strange compilation error occurs
important note when a strange compilation error occurs [message #57296] Sat, 26 June 2021 21:42 Go to next message
BetoValle is currently offline  BetoValle
Messages: 202
Registered: September 2020
Location: Brasil Valinhos SP
Experienced Member
Hi,

Suddenly, through an unnoticed distraction, a strange compilation error occurs.
It happened to me, although it solved with some slowness, because I was evaluating the reason, as that something difficult to visualize in the code suddenly happened (in this case, it involved many lines of code).

the ide show errors like

...'using namespace' is not allowed in classes

...non-friend class member 'Get' cannot have a qualified name


class....{}
   public:
    ....
    ....
    ....
    void getTiposCartao(){; // <----- I accidentally pasted a bracket and didn't notice.
    ....
    ....
 }; 




that's why I think good practices such as writing function and as soon as it ends compiling before writing others function or the next code.

Thanks


Re: important note when a strange compilation error occurs [message #57297 is a reply to message #57296] Sun, 27 June 2021 16:42 Go to previous messageGo to next message
BetoValle is currently offline  BetoValle
Messages: 202
Registered: September 2020
Location: Brasil Valinhos SP
Experienced Member
It is important to highlight that:


function abc() {; // <------------- in this situation the compiler "will not" point to the line where the error occurred!!!

function abc() }; // <------------- in this situation the compiler "will" point to the line where the error occurred!!!



Thanks!
Re: important note when a strange compilation error occurs [message #57298 is a reply to message #57297] Sun, 27 June 2021 17:49 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1075
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello,

According to the standard following line is valid code:
void getTiposCartao(){;

You are opening function scope and add empty instruction. Please noticed that you can place whatever number of semicolons as you want:
void getTiposCartao(){;;;;;;; // <- valid


Why it is so? In C/C++ you are not force to write instruction per line - it is good habbit, but you have flexibility:
void getTiposCartao(){int a = 4;++a;int b = a + 10;for(int i = 0; i < 10; ++i){};;;} // <- You could process universe in the single function ;)


For the readability reason nobody should write code like this... This is not something we could fix within TheIDE. It is how the language is defined.

On the other hand following code:
function abc() };

is invalid due to parenthesis mismatch.
Klugier


U++ - one framework to rule them all.

[Updated on: Sun, 27 June 2021 17:52]

Report message to a moderator

Re: important note when a strange compilation error occurs [message #57299 is a reply to message #57298] Sun, 27 June 2021 20:05 Go to previous message
BetoValle is currently offline  BetoValle
Messages: 202
Registered: September 2020
Location: Brasil Valinhos SP
Experienced Member
Hi Klugier,

I understand your placement.

I don't have experience with c/c++, but considering from beginning to end of the code (total), if not close the bracket and semicolon "};" understand that the compiler will return to the first line of a new function, for example, and will display an error message in the format
(file name);( line); error function definition is not allowed here (this error for my case).

In my case, the error was in the header file "file.h" and the compiler showed the 1st line of another function that was in the file "file.cpp", ie considering large files, the situation was visually difficult to be solved.

Thanks!
Previous Topic: Compile under Mac M1 for intel
Next Topic: Do we have a QR image generator?
Goto Forum:
  


Current Time: Thu Mar 28 22:31:32 CET 2024

Total time taken to generate the page: 0.01807 seconds