Jump to content
43oh

How to select correct include file


Recommended Posts

G'day

I'm porting a sketch from F5529 to Tiva, and want to be able to use the sketch on both (until debugged). I thought the following would work:

 

#define _TIVA true    //true for Tiva, false for F5529

#if (_TIVA)
   #include "TM4C_DS18B20.h"
#else
   #include "GFDS18B20.h"
#endif

 

But I get multiple definition of `DS18B20:.. errors , when I compile.

Is there a way around this.

 

 

Link to post
Share on other sites

Nope again,

Might have to keep a duplicate copy of sketch for each Launchpad.

But my main problem is the unavailability  of the Tiva Serial1 port, but that's in another post.

Sort of stuck between two launchpads, F5529 one runs out of ROM the other has Serial1 problems.

Anyway will push on.

Grant

Link to post
Share on other sites

Hello Grant,

 

For the lm4f (TIVAC), Energia.h (../energia/hardware/lm4f/cores/lm4f/) has the following defines:

#if defined(__TM4C129XNCZAD__)
#define TARGET_IS_SNOWFLAKE_RA0
#define PART_TM4C129XNCZAD
#elif defined(__TM4C1294NCPDT__)
#define TARGET_IS_SNOWFLAKE_RA0
#define PART_TM4C1294NCPDT
#elif defined(__LM4F120H5QR__) || defined(__TM4C123GH6PM__)
#define TARGET_IS_BLIZZARD_RB1
#define PART_TM4C1233H6PM
#define PART_LM4F120H5QR
#else
#error "**** No PART defined or unsupported PART ****"
#endif

Maybe you can use some of these defines?

 

Regards,

Liviu

Link to post
Share on other sites

Whitespace before #include directives should make no difference. Try just doing:

#include "TM4C_DS18B20.h"
unconditionally and see if the problem goes away. I suspect that with most of your attempts you're only getting that file included, and the problem is entirely within it. (Or that something somewhere else is including the conflicting definitions.)
Link to post
Share on other sites

Both includes work OK

 

When I comment out  #include "TM4C_DS18B20.h" and leave  #include "GFDS18B20.h" the sketch is compiles and tests OK for F5529

and when I comment out  #include "GFDS18B20.h" and leave  #include "TM4C_DS18B20.h" the sketch is compiles and tests OK for Tiva.

 

I am trying to use the same sketch(while I port over to Tiva),  by making _TIVA true for Tiva, or _TIVA false for F5529.

 

It appears the compiler  always tests both includes, regardless of _TIVA state . 

Link to post
Share on other sites

G'day

Compied with E14 for a Tiva with the following code

 

#if defined(__TM4C123GH6PM__)
   #include "TM4C_DS18B20.h"
#else
   #include "GFDS18B20.h"
#endif

 

get the following errors

:

GFDS18B20V2\GFDS18B20.cpp.o: In function `DS18B20::DS18B20(unsigned char)':
GFDS18B20.cpp:(.text._ZN7DS18B20C2Eh+0x0): multiple definition of `DS18B20::DS18B20(unsigned char)'
TM4C_DS18B20\TM4C_DS18B20.cpp.o:TM4C_DS18B20.cpp:(.text._ZN7DS18B20C2Eh+0x0): first defined here
GFDS18B20V2\GFDS18B20.cpp.o: In function `DS18B20::DS18B20(unsigned char)':
GFDS18B20.cpp:(.text._ZN7DS18B20C2Eh+0x0): multiple definition of `DS18B20::DS18B20(unsigned char)'

etc. for many many lines

 

It is no longer a big issue as I have now have two sketches, and with the porting is nearly over will only require the sketch to compile on the Tiva. 

Grant

Link to post
Share on other sites

Yes its a linker error that is picking up both includes. But the following should inform the linker what include is to be used, and not Both

 

 

#if defined(__TM4C123GH6PM__)
   #include "TM4C_DS18B20.h"      // use this when compiling with Tiva
#else
   #include "GFDS18B20.h"         //use this when compiling with F5529
#endif

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...