Hello all!
In my game, I have a structure defined as follows:
typedef struct vegetation {
vegetation_type type;
bool harvested;
int wood_yield;
int fruit_content;
int asciiChar;
int color;
char description[];
} vegetation;
Later in the same header, I instantiate this type as follows:
vegetation VEG_NONE = {VEG_TYPE_NONE,false,0,0,0,0,"None"};
This is obviously required, since the flexible array-member cannot be
dynamically initialized.
However, the linker cokes on this with the following error message:
main.c: multiple definition of `VEG_NONE'
graphics.c: first defined here
Why is this? I have properly encapsulated the header file in an
#ifndef,#define, #endif structure. So what could be happening?
--
Cheers,
John den Haan
joDhn[dot]haEan[at]chLello[dot]nl
Remove capital 'DEL' from above addy to obtain e-mail address 4 1322
Never mind, I sorted it out. Looks liek there was a hiatus in my
knowledge concerning multiple inclusion and the use of externs ;)
Thanks anyways
Well then, I got the linker error sorted out.
Now the compiler chokes on the following:
vegetation VEG_GRASS =
{VEG_TYPE_GRASS,false,0,0,ASCII_GRASS,COLOR_GRASS, "Grass"};
It tells me:
error: syntax error before ';' token
It seems to dislike the use of a #defined constant in the initialization
of the struct. What can I do to circumvent this problem? enums seem to
work (as shown by VEG_TYPE_GRASS, which is graciously accepted), but
#define's do not. I;ve tried explicit typecasting of the define, but it
doesn't do the job...
John den Haan wrote:
Well then, I got the linker error sorted out.
Now the compiler chokes on the following:
vegetation VEG_GRASS =
{VEG_TYPE_GRASS,false,0,0,ASCII_GRASS,COLOR_GRASS, "Grass"};
It tells me:
error: syntax error before ';' token
It seems to dislike the use of a #defined constant in the initialization
of the struct. What can I do to circumvent this problem? enums seem to
work (as shown by VEG_TYPE_GRASS, which is graciously accepted), but
#define's do not. I;ve tried explicit typecasting of the define, but it
doesn't do the job...
You have not provided enough information, but I'll guess
that you did something like
#define ASCII_GRASS 'G';
instead of
#define ASCII_GRASS 'G'
--
Eric Sosman es*****@acm-dot-org.invalid
You have not provided enough information, but I'll guess
that you did something like
#define ASCII_GRASS 'G';
instead of
#define ASCII_GRASS 'G'
OMG. You're right :D
--
Cheers,
John den Haan
joDhn[dot]haEan[at]chLello[dot]nl
Remove capital 'DEL' from above addy to obtain e-mail address This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gianni Mariani |
last post by:
I posted a gcc bug
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13332
here is the text:
-----------------------------------------------------------
This code will compile fine but fail on...
|
by: JustSomeGuy |
last post by:
I have a class that has a static member variable.
string x;
x should never change during use and should be intialized to "abcd".
How does one do this?
|
by: fix |
last post by:
Hi all,
I feel unclear about what my code is doing, although it works but I am
not sure if there is any possible bug, please help me to verify it.
This is a trie node (just similar to tree nodes)...
|
by: bvisscher |
last post by:
I posted this recently in microsoft.public.vc.language and was
redirected
here.
I also searched this ng and found some relavant threads.
The most relavent I found was:
...
|
by: Jesper Schmidt |
last post by:
When does CLR performs initialization of static variables in a class
library?
(1) when the class library is loaded
(2) when a static variable is first referenced
(3) when...
It seems that...
|
by: hobbes992 |
last post by:
Howdy folks,
I've been working on a c project, compiling using gcc, and I've reached a problem. The assignment requires creation of a two-level directory file system. No files have to be added or...
|
by: Daniel Rudy |
last post by:
Hello Group.
Please consider the following code:
/* this table is used in the wipedevice routine */
static const struct wipe_t
{
uchar wte; /* wipe table entry */
} wipetable = {...
|
by: Travis |
last post by:
struct Point
{
int x;
int y;
};
Point Lines =
{
{0,1},
{1,2},
|
by: ssylee |
last post by:
I'm not sure if I can initialize members of a struct the lazy way. For
example, let's say I have a struct defined as below:
typedef struct _ABC
{
BOOL A;
BOOL B;
BOOL C;
} ABC;
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |