因此,我尝试将我的项目从Windows XP上的先前版本移至Windows 7上的Visual C++ Express 2010.我找到了各种各样的错误,其中找不到atlbase.h.这不是一个问题,但我想记录我的解决方案对其他人的意义.
从我之前的安装中复制以下PlatformSDK文件并将它们放在我的Windows 7计算机上.
PlatformSDK /包括/ ATL
PlatformSDK /包括/ MFC
PlatformSDK/lib目录
PlatformSDK/src目录/ ATL
然后,我将项目属性中的VC++目录更改为指向这些目录.
包括目录 -
*包括/ ATL
*包括/ MFC
图书馆目录 -
*LIB
来源目录 -
*SRC/ATL
对stdafx.h进行更改
就在这一行之后:#include"atlbase.h"
添加以下行:extern CComModule _Module;
希望你现在准备好了!可能不是,但也许你在路上很顺利.
特别针对2010年,特别是针对C++ ......缺少Vs Professional/Premium(烦人的标准版现在名为Professional)?
visual-studio-express visual-studio visual-c++-2010 visual-c++-2010-express
已安装Windows SDK.我之前使用Visual C++ 2008 Express成功构建了N ++.但是现在2010年我有很多关于以下内容的错误消息sprintf_s:
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\string(676): error C2039: 'sprintf_s' : is not a member of '`global namespace''
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\string(676): error C3861: 'sprintf_s': identifier not found
Run Code Online (Sandbox Code Playgroud)
请帮忙.
我有一个简单的应用程序,我尝试使用VC Express编译并使用:
Microsoft平台SDK for Windows server 2003包含MFC和ATL.现在我有这个简单的代码:
CString strValue("test");
CString s = strValue.Trim();
LPCTSTR lpStr = (LPCTSTR)strValue.Trim()
Run Code Online (Sandbox Code Playgroud)
这给我一个编译错误:c:\ dev\test.cpp(463):错误C2039:'修剪':不是'CString'的成员c:\ program files\microsoft platform sdk for windows server 2003 r2\include\mfc\afx.h(369):看'CString'的声明
我对平台SDK和vc express有问题吗?
c++ mfc compiler-errors visual-studio-2010 visual-c++-2010-express
我已经搜索了几天,以便找到在我的GDI +应用程序上显示文本的可能性.
我尝试使用DrawString()GDI + 的功能,但MSDN上的引用不起作用,因为它与参数列表不匹配.我正在使用Visual C++ 2010 Express.
我更改了MSDN示例以使其编译,如下所示:
LinearGradientBrush* myBrush = new LinearGradientBrush(Rect(0,0,width,height),Color::Red, Color::Yellow, LinearGradientMode::LinearGradientModeHorizontal);
Font* myFont = new Font(hdc);
RectF rect = RectF(10,10,100,100);
graphics.DrawString(TEXT("Look at this text!"),100, myFont,rect,&StringFormat(0,0), myBrush);
Run Code Online (Sandbox Code Playgroud)
我还尝试了另外两个功能:
TextOut(hdc,10,10,TEXT("Text"),6);
DrawText(hdc,TEXT("Text"),0,LPRECT(0),0);
Run Code Online (Sandbox Code Playgroud)
他们都没有在屏幕上显示文字.绘图线,椭圆等工作没有问题.
为什么上面的文字绘图例程不起作用?任何人都能提供一个有效的例子吗?
我一直在谷歌上发布之前,但我还没有找到任何关于这个话题..但我不认为这是一个非常棘手的一个所以请原谅发布:o).
对于一份新工作我正在进入C++,并遵循一些教程.特别是一个是关于MFC,它显示了如何创建项目,选择MFC应用程序等.所以,我在Vista和Win 7上安装了Visual C++ Express 2010,两次都有同样的问题:当我去新项目时,我没有"MFC"菜单.该教程的一些截图,以及Visual C++ 2010上的其他一些截图清楚地表明它可以存在.更具体地说,在左上角我有"安装模板",然后是"Visual C++"和"CLR",Win32"和"General",没有MFC.
因为这些是"已安装的模板",我想我应该安装它,但我没有找到关于该主题的明确指示; 从我发现它应该或多或少从一开始就存在...我也找到了一种方法来通过创建一个Win32应用程序添加MFC DLL,但它似乎并没有完全相同的东西..我也花了一些时间在Visual C++的菜单,但没有找到任何明确的方法来添加像Eclipse中的新模板...
好吧,我希望我能说清楚,我认为这是非常基本的,但如果有人能帮助我,我会非常感激.
干杯文森特
我正在使用一个API来编写#define所有包含文件.我正在使用Visual C++ 2010 Express进行开发,到目前为止它一直很好用.
我在项目中添加了一个新的cpp文件,而不小心添加了一个"Windows窗体".VC警告我,我的项目目前没有使用CLR,我真的想要吗?我点击否,并按预期添加了文件.然而,在那之后,我的项目不再编译.
代码看起来基本上是这样的:
api_header.h:
#define DEFINED_HEADER_NAME "path/to/header/file.h"
Run Code Online (Sandbox Code Playgroud)
stdhpf.h:
#include DEFINED_HEADER_NAME
Run Code Online (Sandbox Code Playgroud)
正如我所说,长时间工作正常.现在我明白了:
错误C2006 ::
'#include'预期文件名,发现'identifier'
致命错误C1083:无法打开包含文件''::没有这样的文件或目录
是什么造成的?我发现一些职位,说是因为具有开启预编译头,但我检查Project properties > Configuration properties > C/C++ / Precompiled headers,它的关闭(我提到的设置路径,因为我是新来的VS,有可能做到这一点不止一种方法... ).
有任何想法吗?
c++ compiler-errors visual-studio visual-c++ visual-c++-2010-express
这是一个程序:
#include <iostream>
using namespace std;
int main() {
cout << "Enter a number";
int i;
cin >> i;
try {
if( i == 0 ) throw 0;
if( i == 2 ) throw "error";
} catch( int i ) {
cout << "can't divide by 0";
}
catch( ... ) {
cout << "catching other exceptions";
}
}
Run Code Online (Sandbox Code Playgroud)
在编译时(Windows 7上的Microsoft Visual C++ 2010 Express),我得到的错误是:
致命错误LNK1169:找到一个或多个多重定义的符号
当我使用Visual C++ 2010 Express的调试器运行程序(server.exe)时,它运行完美,但是当我作为exe运行它时它没有; 它崩溃了"Server.exe已停止工作"对话框.
接下来我将exe重命名为"ServerInstaller.exe"并且它有效,所以我认为这是一个权限错误,但它在管理员模式下不能与"Server.exe"一起使用.
然后我将VC++中的调试器连接到"Server.exe"程序,它在"free.c"中出现了异常.
这个文件中的代码是
void __cdecl _free_base (void * pBlock)
{
int retval = 0;
if (pBlock == NULL)
return;
RTCCALLBACK(_RTC_Free_hook, (pBlock, 0));
retval = HeapFree(_crtheap, 0, pBlock); // Exception thrown in this function
if (retval == 0)
{
errno = _get_errno_from_oserr(GetLastError());
}
}
Run Code Online (Sandbox Code Playgroud)
例外是
Server.exe中0x770ae3be处的未处理异常:0xC0000005:访问冲突读取位置0x3765f8c7.
我检查了pBlock的值,它是0x007f82c0.
我的计划.
我的程序是RakNet服务器,并且已成功删除了一个播放器.服务器正在检查此时来自RakNet的消息
堆栈跟踪回来
ntdll.dll!770ae3be()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!770ae023()
kernel32.dll!75e814dd()
> msvcr100d.dll!_free_base(void * pBlock) Line 50 + 0x13 bytes C
msvcr100d.dll!_free_dbg_nolock(void …Run Code Online (Sandbox Code Playgroud) 可能重复:
没有参数的构造函数上没有括号是语言标准吗?
好的,我有一个泡菜.这是一个错误的C2228问题,我看了其他问题和答案,并没有给出的提示似乎对我有用 - 这是我的第一个问题,我是新手,所以请温柔!注意:如果我使用,程序将编译
Wizard wiz0;
Run Code Online (Sandbox Code Playgroud)
但如果我使用,请不要
Wizard wiz0();
Run Code Online (Sandbox Code Playgroud)
我正在使用的这本书告诉我这两个陈述应该是等价的,所以我试图找出为什么我可以使用一个而不是另一个.
首先,当我尝试使用向导wiz0()时出现错误:
1> Chapter5.cpp
1>Chapter5.cpp(14): error C2228: left of '.fight' must have class/struct/union
1>Chapter5.cpp(15): error C2228: left of '.talk' must have class/struct/union
1>Chapter5.cpp(17): error C2228: left of '.setArmor' must have class/struct/union
1>Chapter5.cpp(19): error C2228: left of '.getName' must have class/struct/union
1>Chapter5.cpp(21): error C2228: left of '.castSpell' must have class/struct/union
Run Code Online (Sandbox Code Playgroud)
这是(我认为)Chapter5.cpp的相关代码是:
Wizard wiz0(); //declares a variable (wiz0) of type Wizard.
wiz0.fight();
wiz0.talk();
wiz0.setArmor(10);
cout << "Player's Name: " << wiz0.getName() << …Run Code Online (Sandbox Code Playgroud) #include <iostream>
#include <direct.h>
using namespace std;
int main() {
if( _mkdir("d:\\a\\b") == 0 ){
cout << "success";
} else if ( _mkdir("d:\\a") == EEXIST ) {
cout << "Directory was not created because dirname is the name of an existing file, directory, or device.";
}
else if ( _mkdir("d:\\a") == ENOENT ) {
cout << "Path was not found.";
}
}
Run Code Online (Sandbox Code Playgroud)
在运行程序时,输出是意外的.(大多数时候是失败.我不知道原因)
有时我看到成功.很多时候,如果我删除双斜杠\\单斜杠\消息是成功的.这件事让我很生气.为什么会这样?有backslashes问题吗?
UPDATE
在visual c ++ 2010 express edition中,当我按下CTRL + …
我已经进行了搜索,但我找不到我搜索的内容.我想用C++和Visual C++ Express 2010创建一个Python模块.现在,我需要包含Python.h,但是当我编译它时说它找不到Python.h.如何为我的VC提供Python头文件?