假设我们这个decl有源文件:
@import url(http://fonts.googleapis.com/css?family=Raleway:400,300,500,600,700,800);
@import url(http://fonts.googleapis.com/css?family=Hind:400,300,500,600,700);
任何在源文件内部函数中使用rtlInitUnicodeString的尝试都需要“重新定义”,如下所示:
typedef VOID ( NTAPI *my_RtlInitUnicodeString ) (
PUNICODE_STRING DestinationString,
PCWSTR SourceString
);
my_RtlInitUnicodeString rtlInitUnicodeString;
//static has same effect
单击任何源文件内部函数中使用的rtlInitUnicodeString的“定义”[VS],总是将我们带到它的主页: Winternl.h 而不是源文件的宽度decl。这是一个编译器限制,还是有另一种方法可以为所有人提供rtlInitUnicodeString和杂项?
答案 0 :(得分:1)
您的程序中不应该有多个变量定义。要使用来自不同编译单元的变量,使用它的每个编译单元应包含带有变量声明的头文件。声明应以关键字“extern”开头。这就是全局变量在C中的工作方式,它与typedef无关。
答案 1 :(得分:0)
在注意到编译错误之前,答案并不明显:
<locale>
有些东西扭结了。但解释为什么
error C2659: '=' : function as left operand
适用于源文件内部函数,但不适用于
my_RtlInitUnicodeString RtlInitUnicodeString = (my_RtlInitUnicodeString) GetProcAddress(hdlNtCreateFile, initUnicodeFnString);
需要超越我的理解。