Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 

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 and Verbose
  • 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
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
#ifdef clause ignored (Read 220 times)
pg
Newbies
*
Offline



Posts: 2
#ifdef clause ignored
May 9th, 2022 at 10:30am
 
Hi,
I'm developing code for Teensy4.0 and 4.1 modules and uses Visual Micro together with VisualStudio2019. For maintenance reasons I'm trying to keep as much of the code as possible common to both modules. I'm using precompiler statements to tailor the source for each module, when necessary. More specifically I'm using two different Ethernet libraries (NativeEthernet for Teensy4.1 and Ethernet for Teensy 4.0).
The include code looks like the following:

#ifdef SV_TEENSY_41
    #include <fnet.h>
    #include <NativeEthernet.h>
    #include <utility/NativeW5100.h>
#endif


#ifdef SV_TEENSY_40
    #include <Ethernet.h>
    #include <utility/w5100.h>
    #include <EthernetClient.h>
#endif

My problem is that regardless of if SV_TEENSY_40 or SV_TEENSY_41 is defined, both libraries get compiled and the linker will then protest on multiple definitions of certain functions since the names are common to both libraries.
Compiling and linking the same code in the Arduino environment works fine, which leads to my question:
Is this problem somehow related to VisualMicro/Visual Studio and if so what to do about it?
I'm attaching the build output.

Any answers or tips are appreciated.
BR
/pg
Back to top
 

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



Posts: 1542
Re: #ifdef clause ignored
Reply #1 - May 9th, 2022 at 10:52am
 
Thanks for the report.

For this to work correctly you must have the below option enabled for the #ifdef statements to be recognised correctly.
vMicro > Compiler > Deep Search for Libraries + Accurate Prototype Insertion (Gcc-E)

Back to top
 
 
IP Logged
 
pg
Newbies
*
Offline



Posts: 2
Re: #ifdef clause ignored
Reply #2 - May 9th, 2022 at 11:04am
 
Hi Simon,

Thanks for such a quick reply!
This resolved my build issue.

Again, thank's a lot!

BR
/pg
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print