Makefile tips
-include $(TARGET_HOME)/.config
-include $(TARGET_HOME)/release.mak
==> while we add the prefix sign "--" in front of include statement, it means that if the include file is not exist, this statement is still ok without any error
Sample Makefile:
all: testLibiptcless1
testLibiptcless1: testLibiptcless1.c
gcc -Wall -Wunused -DNETFILTER_VERSION=\"1.2.6\" -rdynamic -o $@ $< \
/usr/local/lib/iptables.o /usr/local/lib/libiptc.a -ldl ==> We can link the other object file directly in the gcc command, remember be aware put all the linked libraries after the source code/output executed files
Sometimes we need some parameters inside the function (maybe for further usage). But that parameter is currently not used. So we can declare the attribute after the unused parameter. The attribute is declared as following usage.
#if defined(__GNUC__)
# define dlna_unused __attribute__((unused)) ==> define the dlna_unused
#else
# define dlna_unused
#endif
void
soap_device_callback( IN http_parser_t * parser dlna_unused, // we tag the dlna_unused here to quiet the gcc produce the Warning messages
IN http_message_t * request,
INOUT SOCKINFO * info )
-Wunused causes gcc to complain about unused parameters. This is often a good thing, if it makes you check twice whether you mistyped a variable name or forgot to implement something. But sometimes you really need to have a parameter which is not used, perhaps because the function needs to match a particular prototype.
gcc has a __attribute__((unused)) thing you can apply to paramters to quieten the warning. This actually means possibly unused: if you do use the parameter, gcc doesn't complain. So with unused alone, you can make errors in the opposite direction.
沒有留言:
張貼留言