Compilation
The first problem you have to deal with is why the code does not compile. There is a problem in your network_set.h header; this is not self-sufficient in some way, so you need to enable something else before you enable it, or you need to explicitly configure it somehow. You should strive to ensure that your headings are autonomous and idempotent.
- standalone may be included without any other headers preceding it
- idempotent can be enabled multiple times without causing chaos
Self-restraint is achieved by ensuring that it can be the first header included in the source file and then compiled cleanly. This means that if it uses a function (e.g. size_t ), then it includes a header that defines the function (e.g. <stddef.h> ).
Idempotency is achieved by enabling header protection:
#ifndef HEADER_H_INCLUDED #define HEADER_H_INCLUDED ...main body of header... #endif
I use the following script called chkhdr to ensure that the headers are autonomous and idempotent.
#!/bin/ksh
For example:
chkhdr -Itools/net/inc tools/net/inc/network_set.h
Communication
Over time, after fixing compilation problems, you will encounter communication problems. The -lnet_api option -lnet_api for a library named libnet_api.so or libnet_api.a .
To establish a connection with net_api.a , you need to transfer the file path to the communication command:
LIB_DIR = ./tools/net/lib LIB_NET_API = net_api.a LIB_PATH = -L ${LIB_DIR} ${CC} ... ${LIB_DIR}/${LIB_NET_API} ...
Obviously, you could define a macro for the path to the entire library. Notice how I redefined LIB_PATH in terms of the LIB_DIR macro.
Jonathan leffler
source share