Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Compiler keeps forcing C compilation (Read 210 times)
GTiRhil
Newbies
*
Offline


Posts: 3
Joined: May 19th, 2024
Compiler keeps forcing C compilation
Sep 24th, 2025 at 8:22am
Print Post  
Hi

My problem is so generic and idiotic that I can't post code.

When I try to compile my code in Visual Studio it keeps crashing in standard Arduino files when it meets the C++ keyword "class".  For example in the standard SPI.h file.   

I think that it is trying to compile it as C because it reports, for example:

adafruit_spidevice.h:9: In file included from
adafruit_max31865.h:55: from
globals.h:6: from
analogi2c.c:1: from
 
spi.h: 1045:1: error: unknown type name 'class
   1045 | class SPISettings {
   | ^~~~~
 
spi.h: 1045:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   1045 | class SPISettings {

etc.  I've set the project properties to force compilation as C++ but it's just not getting it.

How can I fix it?  Sorry to ask such as dumb question.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2807
Joined: Feb 13th, 2019
Re: Compiler keeps forcing C compilation
Reply #1 - Sep 24th, 2025 at 8:33am
Print Post  
Can you enable the vMicro > Compiler > Verbose option, and build the project again and attach the log?
(This will show the compiler commands and other detail to allow us to replicate)

It also looks like you have "vMicro > Compiler > Deep Search for Libraries + Accurate Prototype Insertion (Gcc-E)" Switched off, which could be impacting the compile as well.
  
Back to top
IP Logged
 
GTiRhil
Newbies
*
Offline


Posts: 3
Joined: May 19th, 2024
Re: Compiler keeps forcing C compilation
Reply #2 - Sep 24th, 2025 at 12:12pm
Print Post  
Hi

I'll attach the verbose record.

The Deep search does seem to be turned on.

Thanks for your help!

Hil
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2807
Joined: Feb 13th, 2019
Re: Compiler keeps forcing C compilation
Reply #3 - Sep 24th, 2025 at 2:55pm
Print Post  
Thanks for the log, it shows there is a file "analogi2c.c" in the project which will be automatically compiled as C as it has the "c" extension.

If this needs to be C++ then rename the file in Solution Explorer to have the "cpp" extension, and after this it will compile it as C++.

Does that help, or am I missing something?
  
Back to top
IP Logged
 
GTiRhil
Newbies
*
Offline


Posts: 3
Joined: May 19th, 2024
Re: Compiler keeps forcing C compilation
Reply #4 - Sep 25th, 2025 at 8:05am
Print Post  
I don't know whether you are missing something or not!  It seems that I am.

I hadn't been getting these errors before, but suddenly I do.

I took the easy way out and renamed everything to cpp.  I tried changing the project options in Visual Studio to C++ but that didn't help.   

Thanks for your help Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint