handel-c library file

hello,

I want to build tcp/ip-Stack as an library file. The stack contains one tcp.hcc-file with the main-function and and some other macros and functions. The second file is a headerfile where all the variables are declared and the macro/functions-prototypes are in it. Its my first time building a library file at all.

  1. I think I have to put the main-function in the file which should later include the library file (its not allowed to have a main-function in a library-file, or), is it right???
2.I did that, I made a new project which includes the tcp.hcl the code of the project is only the tcp-mainfunction from the old tcp.hcc file
  1. No there are a lot of errors, some var. are undeclared and some are redifined.

can somebody help me,thanks, michael

Reply to
Raven76
Loading thread data ...

hello,

I want to build tcp/ip-Stack as an library file. The stack contains one tcp.hcc-file with the main-function and and some other macros and functions. The second file is a headerfile where all the variables are declared and the macro/functions-prototypes are in it. Its my first time building a library file at all.

  1. I think I have to put the main-function in the file which should later include the library file (its not allowed to have a main-function in a library-file, or), is it right???
2.I did that, I made a new project which includes the tcp.hcl the code of the project is only the tcp-mainfunction from the old tcp.hcc file
  1. No there are a lot of errors, some var. are undeclared and some are redifined.

can somebody help me,thanks, michael

Reply to
Raven76

macro/functions-prototypes

main-function

It sounds like you are getting multiple definitions, which isn't allowd in C (or HandelC).

The approach many people take is to create a "sentinel" in the header file so that it can only be included once.

So in your header file tcp.hcc, put

#ifndef TCP_HCC #define TCP_HCC

/* all the code from the header you wrote */

#endif

and that makes sure that if a file in your design includes tcp.hcc twice, it only really gets included once.

I hope this helps,

regards

Alan

--
Alan Fitch
Consultant
 Click to see the full signature
Reply to
Alan Fitch

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.