cfaqs

definitions && declarations

When you need to share variables or functions across several source files, you will of course want to ensure that all definitions and declarations are consistent. The best arrangement is to place each definition in some relevant .c file. Then, put an external declaration in a header (``.h'') file, and #include it wherever the declaration is needed. The .c file containing the definition should also #include the same header file, so the compiler can check that the definition matches the declarations.

typedef &&  #define

consider these declarations:

	typedef char *String_t;
	#define String_d char *
	String_t s1, s2;
	String_d s3, s4;
s1s2, and s3 are all declared as char *, but s4 is declared as a char, which is probably not the intention. 


原文地址:https://www.cnblogs.com/invisible/p/1958164.html