handel-c library file

Jun 09, 2004 2 Replies

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


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

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 DOULOS - Developing Design Know-how VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project Services Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK Tel: +44 (0)1425 471223 mail: alan.fitch@doulos.com Fax: +44 (0)1425 471573 Web: http://www.doulos.com The contents of this message may contain personal views which are not the views of Doulos Ltd., unless specifically stated.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required