已在* .obj中定义的C ++外部变量

时间:2017-02-19 22:29:10

标签: c++ compiler-errors linker

在头文件中,我有一个名称空间,用于存储一些用作全局变量的外部指针。然后,此头文件包含在使用其实现的几个.cpp文件中。当我编译时,我得到每个全局的错误:

# Verify that %USERPROFILE% is defined.
> $env:USERPROFILE
C:\Users\jdoe

# Verify that %USERPROFILE% is defined in the registry.
> Get-ItemPropertyValue 'HKCU:\Volatile Environment' USERPROFILE
C:\Users\jdoe

# Verify that the API call to retrieve the known folder
# "Personal" (Documents) returns the expected value.
> [Environment]::GetFolderPath('Personal')
C:\Users\jdoe\Documents

# See if the registry contains the expected definition.
> Get-ItemPropertyValue 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders' Personal
C:\Users\jdoe\Documents

如何在标题中写入变量:

LNK2005 "void * Globals::gHandle" already defined in Engine.obj 

头文件使用#ifndef所以我不应该多次包含。有些函数可以获取或设置这些全局变量的值。

0 个答案:

没有答案