点击(此处)折叠或打开
- /* main.c */
- #include <string.h>
- #include <stdio.h>
- #define WEAK __attribute__ ((weak))
- //#define WEAK __weak
- int WEAK foo(int);
- #pragma weak foo = default_foo
- int main()
- {
- int iret = foo(10);
- printf("[%d]\n", iret);
- }
- int default_foo(int arg)
- {
- return arg;
- }
点击(此处)折叠或打开
- #include <string.h>
- int foo(int a)
- {
- return a*10;
- }
点击(此处)折叠或打开
- TARGET = foo
- SOURCE = main.c pub.c
- OBJS = $(SOURCE:.c=.o)
- .c.o:
- gcc -o ${@} -c ${<}
- all: ${TARGET}
- ${TARGET}: ${OBJS}
- gcc -o $@ ${OBJS}
其他还有
- #define PACK_END __attribute__((packed)) /*用于限定结构体单字节对齐*/
- typedef struct
- {
- UINT8 channelNumber;
- UINT64 startTime;
- UINT16 duration;
- } PACK_END IEEEtypes_Common11hHdr_MeasReq_t;
- //另外有些编译要求的语法为
- typedef __packed struct
- {
- UINT8 channelNumber;
- UINT64 startTime;
- UINT16 duration;
- } IEEEtypes_Basic_MeasReq_t