本文介绍了静态外部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 问题: A.cpp: ------ 静态FOO * gFoo = NULL; 啊 extern FOO * gFoo; 给出:L2001 - 未解析的外部:" symbol struct FOO * gFoo" 如果Ah看起来像: extern static FOO * gFoo; 它给出: C2159:指定了多个存储类。 < blink,blink> 我现在该怎么做?我有一个prefedined宏,它会产生一个 静态FOO *。我想告诉我所有其他的.cpp文件,它们是stdafx.h中存在的。 谢谢你, - -Gernot int main(int argc,char ** argv){printf ("%silto%c%cf %cgl%ssic%ccom%c"," ma",58,''g'',64," ba",46,10);} ________________________________________ 想找个好游戏吗?亲自动手吧! GLBasic - 你可以这样做 www.GLBasic .com Problem: A.cpp:------static FOO* gFoo=NULL; A.hextern FOO* gFoo; gives: L2001 - unresolved external: "symbol struct FOO* gFoo" if A.h looks like:extern static FOO* gFoo; it gives:C2159: more than one storage class specified. <blink, blink>How would I do this now? I have a prefedined macro that makes a"static FOO*". And I want to tell all my other .cpp files that itexists in stdafx.h. Thank you,---Gernotint main(int argc, char** argv) {printf("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, ''g'', 64, "ba", 46, 10);} ________________________________________Looking for a good game? Do it yourself!GLBasic - you can do www.GLBasic.com推荐答案 解决方案: A.cpp: ------ FOO * gFoo = NULL; //注意没有静态 啊 ---- extern FOO * gFoo; HTH Mark Solution: A.cpp:------FOO* gFoo=NULL; // Note no static A.h----extern FOO* gFoo;HTH Mark 我重写了代码,所以我现在可以这样做。但我不明白。 为什么我不能告诉另一个.cpp文件,其他地方有静态变量 ? -Gernot I rewrote the code so I can do this now. But I don''t understand it.Why can''t I tell another .cpp file that there is an static variablesomewhere else?-Gernot 这篇关于静态外部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-25 01:42