0

I'm trying to run a simple hello world on my pc but when I try to compile it I have a lot of errors coming from Cmath, stdio, stdlib. I've thought about the environment variable but I don't know where it could come from.

I've tried to create another project and reinstalled visual studio. I'm on windows 8.1, have windows sdk and use visual studio 2015 community.

My code for the hello world:

#include "stdafx.h"
#include <iostream>

int main()
{
    std::cout<<"hello world"<<std::endl;
    return 0;
}

Here is the output:

1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
1>  stdafx.cpp
1>d:\visual studio\vc\include\stdio.h(295): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(295): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(297): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(297): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(297): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(304): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(304): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(304): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(307): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(307): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(307): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(316): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(316): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(316): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(318): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(318): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(318): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(321): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(321): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(321): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(322): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(322): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(322): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(345): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(345): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(345): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(349): warning C4003: not enough actual parameters for macro '__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST_EX'
1>d:\visual studio\vc\include\stdio.h(349): error C2146: syntax error: missing ';' before identifier '_vsnprintf'
1>d:\visual studio\vc\include\stdio.h(349): error C2143: syntax error: missing ',' before '*'
1>d:\visual studio\vc\include\stdio.h(349): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(349): error C2199: syntax error: found 'char (' at global scope (was a declaration intended?)
1>d:\visual studio\vc\include\stdio.h(349): error C2062: type 'char' unexpected
1>d:\visual studio\vc\include\stdio.h(352): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(352): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(352): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(357): warning C4003: not enough actual parameters for macro '__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST'
1>d:\visual studio\vc\include\stdio.h(357): error C2146: syntax error: missing ';' before identifier 'vsprintf'
1>d:\visual studio\vc\include\stdio.h(357): error C2143: syntax error: missing ',' before '*'
1>d:\visual studio\vc\include\stdio.h(357): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(357): error C2365: 'sprintf': redefinition; previous definition was 'data variable'
1>  d:\visual studio\vc\include\stdio.h(357): note: see declaration of 'sprintf'
1>d:\visual studio\vc\include\stdio.h(390): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(390): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(390): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(393): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(393): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(393): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(402): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(402): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(402): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(457): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(457): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(457): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(461): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(461): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(461): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(468): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(468): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(468): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(470): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(470): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(470): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(474): warning C4003: not enough actual parameters for macro '__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST_EX'
1>d:\visual studio\vc\include\stdio.h(474): error C2146: syntax error: missing ';' before identifier '_vsnwprintf'
1>d:\visual studio\vc\include\stdio.h(474): error C2143: syntax error: missing ',' before '*'
1>d:\visual studio\vc\include\stdio.h(474): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(474): error C2199: syntax error: found 'wchar_t (' at global scope (was a declaration intended?)
1>d:\visual studio\vc\include\stdio.h(474): error C2062: type 'wchar_t' unexpected
1>d:\visual studio\vc\include\stdio.h(502): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(502): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(502): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(505): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(505): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(505): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(512): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(512): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(512): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(514): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(514): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(514): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(530): warning C4003: not enough actual parameters for macro '__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST_EX'
1>d:\visual studio\vc\include\stdio.h(530): error C2146: syntax error: missing ';' before identifier '_swprintf_s'
1>d:\visual studio\vc\include\stdio.h(530): error C2143: syntax error: missing ',' before '*'
1>d:\visual studio\vc\include\stdio.h(530): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(530): error C2146: syntax error: missing ';' before identifier 'vswprintf_s'
1>d:\visual studio\vc\include\stdio.h(530): error C2733: 'vswprintf_s': second C linkage of overloaded function not allowed
1>  d:\visual studio\vc\include\stdio.h(461): note: see declaration of 'vswprintf_s'
1>d:\visual studio\vc\include\stdio.h(531): warning C4003: not enough actual parameters for macro '__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_ARGLIST_EX'
1>d:\visual studio\vc\include\stdio.h(531): error C2146: syntax error: missing ';' before identifier '__vswprintf_l'
1>d:\visual studio\vc\include\stdio.h(531): error C2143: syntax error: missing ',' before '*'
1>d:\visual studio\vc\include\stdio.h(531): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(531): error C2146: syntax error: missing ';' before identifier '_vswprintf_s_l'
1>d:\visual studio\vc\include\stdio.h(531): error C2733: '_vswprintf_s_l': second C linkage of overloaded function not allowed
1>  d:\visual studio\vc\include\stdio.h(505): note: see declaration of '_vswprintf_s_l'
1>d:\visual studio\vc\include\swprintf.inl(40): error C3861: '_crt_va_start': identifier not found
1>d:\visual studio\vc\include\swprintf.inl(42): error C3861: '_crt_va_end': identifier not found
1>d:\visual studio\vc\include\swprintf.inl(64): error C3861: '_crt_va_start': identifier not found
1>d:\visual studio\vc\include\swprintf.inl(66): error C3861: '_crt_va_end': identifier not found
1>d:\visual studio\vc\include\swprintf.inl(88): error C3861: '_crt_va_start': identifier not found
1>d:\visual studio\vc\include\swprintf.inl(89): error C3861: '_vswprintf': identifier not found
1>d:\visual studio\vc\include\swprintf.inl(90): error C3861: '_crt_va_end': identifier not found
1>d:\visual studio\vc\include\swprintf.inl(99): error C3861: '_vswprintf': identifier not found
1>d:\visual studio\vc\include\swprintf.inl(108): error C3861: '_crt_va_start': identifier not found
1>d:\visual studio\vc\include\swprintf.inl(109): error C2660: '__vswprintf_l': function does not take 4 arguments
1>d:\visual studio\vc\include\swprintf.inl(110): error C3861: '_crt_va_end': identifier not found
1>d:\visual studio\vc\include\swprintf.inl(119): error C2660: '__vswprintf_l': function does not take 4 arguments
1>d:\visual studio\vc\include\stdio.h(571): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(571): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(571): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(573): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(573): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(573): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(576): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(576): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(576): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(577): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(577): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(577): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(581): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(581): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(581): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\stdio.h(583): error C2144: syntax error: 'int' should be preceded by ';'
1>d:\visual studio\vc\include\stdio.h(583): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\stdio.h(583): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\wchar.h(968): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\wchar.h(968): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\wchar.h(968): error C2146: syntax error: missing ';' before identifier 'errno_t'
1>d:\visual studio\vc\include\wchar.h(986): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\wchar.h(986): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\wchar.h(986): error C2146: syntax error: missing ';' before identifier 'errno_t'
1>d:\visual studio\vc\include\wchar.h(1015): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\wchar.h(1015): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\wchar.h(1015): error C2146: syntax error: missing ';' before identifier 'errno_t'
1>d:\visual studio\vc\include\wchar.h(1022): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\wchar.h(1022): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\wchar.h(1022): error C2146: syntax error: missing ';' before identifier 'errno_t'
1>d:\visual studio\vc\include\wchar.h(1042): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\wchar.h(1042): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\wchar.h(1042): error C2146: syntax error: missing ';' before identifier 'errno_t'
1>d:\visual studio\vc\include\wchar.h(1053): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\wchar.h(1053): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\wchar.h(1053): error C2146: syntax error: missing ';' before identifier 'errno_t'
1>d:\visual studio\vc\include\wchar.h(1062): error C2144: syntax error: 'wchar_t' should be preceded by ';'
1>d:\visual studio\vc\include\wchar.h(1062): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\wchar.h(1062): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\wchar.h(1074): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\wchar.h(1074): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\wchar.h(1074): error C2146: syntax error: missing ';' before identifier 'errno_t'
1>d:\visual studio\vc\include\wchar.h(1078): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\visual studio\vc\include\wchar.h(1078): error C2086: 'int _CRTIMP_ALTERNATIVE': redefinition
1>  d:\visual studio\vc\include\stdio.h(295): note: see declaration of '_CRTIMP_ALTERNATIVE'
1>d:\visual studio\vc\include\wchar.h(1078): fatal error C1003: error count exceeds 100; stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Marged
  • 10,577
  • 10
  • 57
  • 99
  • 5
    first of all: you don't need stdafx to compile this code. – Marged Dec 28 '15 at 22:33
  • 1
    Well, they do if they used defaults during the VS wizard to make their project. Otherwise the compiler will puke. They could change the setting, but if they're here for this I doubt they're knowledgeable enough to. – Edward Strange Dec 28 '15 at 22:37
  • Are you sure you are compiling this as a C++ program and not as a C one? – vsoftco Dec 28 '15 at 22:42
  • Yeah, i know, i've just created a new win32 consoleApplication project and it was there. But if i removed it or not it change nothing. doesn't visual studio compile in c++ mainly? If i just use it after the install without modification? –  Dec 28 '15 at 22:43
  • I've checked. And run the program in a complete empty project (without stdafx, just the main), i've precised in the properties to build in c++ but the error are still here. I've found an other stackoverflow subject who are my error but it's not solved :http://stackoverflow.com/questions/32222166/hello-world-c-error-cmath –  Dec 29 '15 at 12:03
  • you need to choose "empty solution" when creating win32 console project, otherwise stdafx.h will be there – phuclv Mar 24 '16 at 08:40

2 Answers2

0

Your code looks fine, (apart from the include "stdafx.h", which you mentioned you removed in a comment), so it is probably something to do with your project setup. Try creating a new project, but try making an 'Empty Project' instead, found under the 'Visual C++' then 'General' tab.

  • I've tried, with an empty project my hello world still not working. Something strange is that code bug(which does nothing) :`#include int main() { return 0; }` But it don't bug if i remove the #include. Maybe there is something incorrectly configurate in my pc? –  Dec 29 '15 at 15:31
  • Yes, it is most likely an installation issue. Navigate to "C:\Program Files (x86)\Microsoft Visual Studio (verison no. here - pick latest)\ VC\include". Here is where you should be able to find a file called 'iostream'. If you can't find this file, it may be worth reinstalling as several things are probably wrong with the installation. – TheInfernalCow Dec 29 '15 at 17:00
  • Yes in my folder visual studio, i've a file named iostream with no extension. The system variable could be the problem no? –  Dec 29 '15 at 17:28
  • Firstly, just check that pre-compiled headers are properly disabled - right click on your project in the left bar, go to configuration properties->c/c++->Precompiled Headers and make sure that the 'Precompiled Header' field is set to 'Not using Precompiled Headers' – TheInfernalCow Dec 29 '15 at 17:46
  • It was the default setting, So no changement –  Dec 29 '15 at 17:52
  • Make sure your file is named 'main.cpp' - this should be the only file in your project. It seems like the compiler is trying to compile a file called 'stdafx.cpp' - if this is in your project directory, try deleting it (or renaming it to something else temporarily) and try re-running. – TheInfernalCow Dec 29 '15 at 18:06
  • I don't have stdafx in my project. The only file i have is main.cpp in the folder Source Files. I have an empty Resource files, an empty Header Files and and empty References. The external Dependencies are empty if i remove the #include , but if i let it, i have a lot of dependencies like "ammintrin.h", arm_neon.h","cerrno","cfloat" etc etc... –  Dec 29 '15 at 18:15
0

Not sure if you are still looking for the solution.

See the following article on the Visual C++ Team Blog: "Introducing the Universal CRT" (http://blogs.msdn.com/b/vcblog/archive/2015/03/03/introducing-the-universal-crt.aspx).

Your project is missing that directory (C:\Program Files (x86)\Windows Kits\10\Include\10.0.10069.0\ucrt) from its include path. Ideally, your project should derive its IncludePath from the IncludePath set by the built-in Visual C++ targets that we provide with Visual Studio. If you do that, then this header would be picked up automatically. If you choose not to do this, you'll need to add this directory to your IncludePath (preferably by adding $(UniversalCRT_IncludePath)

  • Thanks for your help. But i've made use of the format of my PC to get a clean install of my c++ environment. Now it's working. But it's not a easy solution^^. –  Mar 24 '16 at 09:20