#use directive giving problems, Need help

I have a sample code that has the #use directive that uses a set of .lib files.
First I got the error saying that the files cannot be found. Then I placed the locations of the .lib files in the LIB.DIR in Dynamic C installation Directory.

But now when I compile the main code, the compiler says I havent defined the functions that are in those lib files.

So I tested some simple code.

the setLED.lib has the following code:

void setbulb(int value);

void setbulb(int value)
{
BitWrPortI(PBDR, &PBDRShadow, value, 7);

}

the libTest.c, which is my main program, has the following code.

#use setLED.LIB //Tried this with the “SETLED.LIB” too. No result. :frowning:

main()
{

setbulb(1);

}

How can I get this code to compile correctly?. Please correct my code if I have done any obvious mistakes.
Thanks.

I don’t know if you did it, but in the *.lib file, you must begin every function declaration with /BeginHeader Func/ etc. It took me a while to figure out that it isn’t just comments, but actually needed by the compiler for some reason.

for example this is my file measure.lib


/*** BeginHeader */
#ifndef __measure_lib
#define __measure_lib
/*** EndHeader */


/*** BeginHeader measurefunc */
void measurefunc(void);
/*** EndHeader */


void measurefunc(void)
{
    printf("
");
}

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


so yours will look something like


/*** BeginHeader */
#ifndef __setLED_lib
#define __setLED_lib
/*** EndHeader */


/*** BeginHeader setbulb */
void setbulb(int value);
/*** EndHeader */

void setbulb(int value)
{
BitWrPortI(PBDR, &PBDRShadow, value, 7);

}

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


I’ll try it out. Thanks for the help
Geez, comments interacting with the code!! :eek: :eek:
First time I saw such a thing. Thanks for pointing it out. I would have never seen such a thing.:slight_smile: :slight_smile: