Дебаг проходит нормально, а вот после компиляции вот что говорит...
------ Build started: Project: getusername, Configuration: Debug Win32 ------
Compiling...
stdafx.cpp
Compiling...
getusername.cpp
c:\documents and settings\administrator\my documents\visual studio 2005\projects\getusername\getusername\getusername.cpp(23) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\getusername\getusername\Debug\BuildLog.htm"
getusername - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Здравствуйте, xinom, Вы писали:
X>Дебаг проходит нормально, а вот после компиляции вот что говорит...
X>------ Build started: Project: getusername, Configuration: Debug Win32 ------
X>Compiling...
X>stdafx.cpp
X>Compiling...
X>getusername.cpp
X>c:\documents and settings\administrator\my documents\visual studio 2005\projects\getusername\getusername\getusername.cpp(23) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
X>Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\getusername\getusername\Debug\BuildLog.htm"
X>getusername - 1 error(s), 0 warning(s)
X>========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
X>
Ну и есть строка
#include "stdafx.h" в файле
getusername.cpp ?
Здравствуйте, xinom, Вы писали:
X>Дебаг проходит нормально, а вот после компиляции вот что говорит...
X>------ Build started: Project: getusername, Configuration: Debug Win32 ------
X>Compiling...
X>stdafx.cpp
X>Compiling...
X>getusername.cpp
X>c:\documents and settings\administrator\my documents\visual studio 2005\projects\getusername\getusername\getusername.cpp(23) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
X>Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\getusername\getusername\Debug\BuildLog.htm"
X>getusername - 1 error(s), 0 warning(s)
X>========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
X>
Потому что в проекте указано, что он с pre-compile headers, а в файле .cpp отсутствует #include <stdafx.h> (собственно сам хедер)
Собсно сразу увидел и добавил, но теперь ругнулся на синтаксис, хм...
c:\documents and settings\administrator\my documents\visual studio 2005\projects\getusername\getusername\getusername.cpp(13) : error C2065: 'DWORD' : undeclared identifier
c:\documents and settings\administrator\my documents\visual studio 2005\projects\getusername\getusername\getusername.cpp(13) : error C2146: syntax error : missing ';' before identifier 'nUserName'
c:\documents and settings\administrator\my documents\visual studio 2005\projects\getusername\getusername\getusername.cpp(13) : error C2065: 'nUserName' : undeclared identifier
c:\documents and settings\administrator\my documents\visual studio 2005\projects\getusername\getusername\getusername.cpp(14) : error C3861: 'GetUserName': identifier not found
c:\documents and settings\administrator\my documents\visual studio 2005\projects\getusername\getusername\getusername.cpp(15) : error C2065: 'cout' : undeclared identifier
c:\documents and settings\administrator\my documents\visual studio 2005\projects\getusername\getusername\getusername.cpp(15) : error C2065: 'endl' : undeclared identifier
c:\documents and settings\administrator\my documents\visual studio 2005\projects\getusername\getusername\getusername.cpp(18) : error C2065: 'cerr' : undeclared identifier
c:\documents and settings\administrator\my documents\visual studio 2005\projects\getusername\getusername\getusername.cpp(19) : error C3861: 'GetLastError': identifier not found
Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\getusername\getusername\Debug\BuildLog.htm"
getusername - 8 error(s), 0 warning(s)
сырец от
туда взял
Здравствуйте, xinom, Вы писали:
X>Собсно сразу увидел и добавил, но теперь ругнулся на синтаксис, хм...
X>X>c:\documents and settings\administrator\my documents\visual studio 2005\projects\getusername\getusername\getusername.cpp(15) : error C2065: 'cout' : undeclared identifier
боян :)Автор: remark
Дата: 02.01.08
Код в
http://tangentsoft.net/wskfaq/examples/src/getusername.cpp не соответствует современному C++. Подробрее: ищи про пространство имен std:: , заголовочные файлы #include <iostream> (без h)
Здравствуйте, xinom, Вы писали:
X>Дебаг проходит нормально, а вот после компиляции вот что говорит...
X>------ Build started: Project: getusername, Configuration: Debug Win32 ------
X>Compiling...
X>stdafx.cpp
X>Compiling...
X>getusername.cpp
X>c:\documents and settings\administrator\my documents\visual studio 2005\projects\getusername\getusername\getusername.cpp(23) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
X>Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\getusername\getusername\Debug\BuildLog.htm"
X>getusername - 1 error(s), 0 warning(s)
X>========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
X>
Возможно, отсутствует сам precompiled header (файл с расширением .pch). Тогда его вначале нужно создать.
В свойствах проекта в опциях компилятора стоит указать Create Precompiled Header(/Yc). Будет сгенерирован pch-файл,
который можно будет использовать. Потом это свойство снова нужно будет изменить на Use Precompiled Header(/Yu).
У меня такая проблема возникала, когда я делал Rebuild всего проекта.
Во время этой операции предыдущий pch-файл был удален, а новый не создан.