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 VS2015 include same lib twice (Read 2657 times)
Daniel Oliveira
Newbies
*
Offline


Posts: 2
Joined: Aug 25th, 2016
VS2015 include same lib twice
Aug 25th, 2016 at 4:06pm
Print Post  
Hello all,

First of all I would like to thank you for this great project and community Smiley

I have a question regarding library inclusion. I have some experience in C++ but not in Arduino environment.

I would like to know how can I include the same library in both the .ino file and in a class present in a .cpp file plus the header file that is also included in by the .ino fie.

I've tried to include the library.h and the class.h file in the .ino file and then include again the library.h in the class.h and I get the multiple errors like:


Code
Select All
MySensorWrapperBH1750.cpp.o (symbol from plugin)*: In function wakeUp1()
(.text+0x0)*: multiple definition of _wakeUp1Interrupt
MySensorGeneric.cpp.o (symbol from plugin)*: (.text+0x0): first defined here

collect2.exe*: error: ld returned 1 exit status

Error compiling for board Arduino Nano w/ ATmega328 



Where MySensorWrapperBH1750 is my class, MySensorGeneric is my .ino file and wakeUp1 is a function of the imported library.


Thank you all in advance
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: VS2015 include same lib twice
Reply #1 - Aug 25th, 2016 at 4:41pm
Print Post  
Hi,

Yes you can include twice but make sure headers have a check for "once"

I see many new Arduino library headers have this at the top
Code
Select All
#pragma once 



Historically Arduino has always recommended using a define to prevent multiple compilation in .h files
Code
Select All
#ifndef HEADER1_H
#define HEADER1_H

... code ...

#endif // HEADER1_H 



« Last Edit: Aug 25th, 2016 at 4:41pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Daniel Oliveira
Newbies
*
Offline


Posts: 2
Joined: Aug 25th, 2016
Re: VS2015 include same lib twice
Reply #2 - Aug 27th, 2016 at 5:51pm
Print Post  
Thank you,

That helped and I was able to import it.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint