While trying to verify the code with the Arduino IDE v2.3.2, i get the following error message:
Flags.h:6:1: error: unknown type name 'namespace'
Flags.h:6:17: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
Flags.c:4:1: error: unknown type name 'namespace'
Flags.c:4:17: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token
I did check that the files had the correct extension, and im lost what is the exact problem with the compiler. Any help is appreciated (and sorry if the code isnt formatted, dunno how it is done)
Double checked again, File explorer recognize the files with the .cpp and .hpp extensions. I just wanted to work the namespace with a library, but the compiler just read them as .c and h. files. Weird think, since i have c++ classes in the code that works without any issues.
Hi @durian321. I'm going to ask you to provide the full verbose output from a compilation.
This procedure is not intended to solve the problem. The purpose is to gather more information.
Please do this:
Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
The "Preferences" dialog will open.
Check the box next to "Show verbose output during: ☐ compile" in the "Preferences" dialog.
Click the "OK" button.
The "Preferences" dialog will close.
Select Sketch > Verify/Compile from the Arduino IDE menus.
Wait for the compilation to fail.
You will see a "Compilation error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
Open a forum reply here by clicking the "Reply" button.
Click the <CODE/> icon on the post composer toolbar.
This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
This will paste the compilation output into the code block.
Move the cursor outside of the code block markup before you add any additional text to your reply.
Click the "Reply" button to post the output.
In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here.
Open a forum reply here by clicking the "Reply" button.
Click the "Upload" icon () on the post composer toolbar:
The "Open" dialog will open.
Select the .txt file you saved from the "Open" dialog.
Click the "Open" button.
The dialog will close.
Click the "Reply" button to publish the post.
Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.
Took a bit of time since it was a big log file, but here it is. For context, im using the current version of my code since that's where the problem is happening.
If looking for it with your file manager or command line, note that the C:\Users\<username>\AppData folder is hidden by default. On Windows "File Explorer", you can make it visible by opening the "View" menu, then checking the box next to "☐ Hidden items".
Please be careful when deleting things from your computer. When in doubt, back up!
After deleting that folder, try compiling or uploading your sketch again. Hopefully this time it will work without any problems.
By deleting that file the sketch does compile now an uploads correctly on the microcontroller. Can you pinpoint exactly why did the error happened? Just in case it happens again and know how to fix it myself.
At some point, you must have named the file Flags.c. When you compiled the sketch, that was cached in the temporary build folder at C:\LOCAL_PATH\Temp\arduino\sketches\58B3E49F811101638F5A0EBC7DEB3C54. The bug causes the file to remain in the compilation cache even after you changed the name to the appropriate Flags.cpp.
If if happens again, examine the compilation output to find the location of the temporary build folder (each sketch has its own build folder, so it won't necessarily be the same name as it was this time), then delete that folder. Deleting the folder clears the bad compilation cache, and the cache will be regenerated the next time you compile so you don't permanently lose anything by deleting that folder.