If the header file is included in multiple C files, this is why you are seeing 
the multiple definition error. It is more correct to put the definition in one 
C file only, then put a declaration in the header file:

Strings.c:
const char AverageCurrentDisp[]   = "Bat Avg Current";

Strings.h:
extern const char AverageCurrentDisp[];

This will ensure there is only one definition of the string, but it can be used 
in any file if you include strings.h.

I don't quite understand your other question, .text is ROM (.data and .bss are 
RAM). Hopefully if you define your strings this way the problem will vanish? If 
not, try removing code until your project compiles, it may be possible that you 
have simply run out of code space. Try turning optimisation on with -O2 cflag.

Good luck! Let us know if you have more troubles.

- Wayne

Sent via BlackBerry® from Vodafone

-----Original Message-----
From: Flugeldorph <[email protected]>

Date: Fri, 13 Feb 2009 10:54:22 
To: <[email protected]>
Subject: [Mspgcc-users]  multiple definition of ...



Hello,

   I have been using the IAR compiler for my work with an msp430F135 mcu.
The client that I am working for was going to purchase a license to IAR, but
thought the price too high. So, a few days ago, I began the task of setting
up a gcc environment (including CodeBlocks), and adjusting my code to work
with the new environment. I had definde all of my strings that I displayed
on an LCD using #defines  like:

#define AverageCurrentDisp   "Bat Avg Current"

I soon discovered that when I used these precompiler directives in gcc, the
string was given an address which began at 0xfc00, and quickly over running
the .text section. So, I looked in the manual, and found out that if I
defined the strings as constants, they would be allocated in the main ROM
space... SO, I created a module 'Constants.h' like

const char AverageCurrentDisp[]   = "Bat Avg Current";

Now I have a new problem. In spite of the fact that I use a

#ifndef __Constant__h
#define __Constant__h
#endif

around my new .h file, I am getting an error message:

obj\Debug\Display.o:(.text+0x30): multiple definition of
`AverageCurrentDisp'

What am I doing wrong, and why does it seem as though the string is still
being placed in the .text section?

--
View this message in context: 
http://www.nabble.com/multiple-definition-of-...-tp22002722p22002722.html
Sent from the MSP430 gcc - Users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to