Can global auto variables be declared in h files? [duplicate]
问题 This question already has an answer here : extern auto variable has no initializer (1 answer) Closed 4 months ago . Somewhat similar to this post, but still different: can I define a global auto variable in some header file? I tried using the following files, but couldn't make them compile. $ cat main.cpp auto a = 5; #include "defs.h" int main(int argc, char **argv){ return a; } $ cat defs.h #ifndef __DEFS_H__ #define __DEFS_H__ extern auto a; #endif And after standard compilation ( g++ main