How to share an enum between a .c file and a .lib file

Hi All,

I am in a position where I have to modify one of the standard .lib files to refer to various structs and enums that where previously in the main C application file.

My approach was to create a common definitions .lib file, put all the definitions that need to be shared in there, then #use that file in both the main.c and the .lib file I need to modify.

I made the mods then tried to compile everything, but DC doesn’t like the enums being put in this common defns .lib file, I get an error of the form:

line 14 : ERROR COMMON_DEFNS.LIB : NUMTAGS previously defined.

So in DC how do you share enum and struct defns between a .c and a .lib file.

Thank you for any responses,
Fred

Hi Fred,

You have several options here including the following:

(a) put the #use for your lib at the beginning of main.c only. This should work as once the lib is pulled in , any subsequent lib files will see any enums, structs, macros etc defined in it.

(b) start your lib file off with

/*** BeginHeader /
#ifndef _DEFNS_LIB
#define _DEFNS_LIB
/
** EndHeader */

and end it with

/*** BeginHeader /
#endif
/
** EndHeader */

This ensures that if the lib file is #used more than once in the project that only the first #use will actually count as the second and subsequent inclusions will effectivly include an empty file as _DEFNS_LIB will have already been defined.

Regards,
Peter