d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > C Compiling/saving Issue
Add Reply New Topic New Poll
Member
Posts: 8,250
Joined: May 10 2012
Gold: 0.00
Feb 5 2017 02:38pm
I am in a C class. Professor wants us to use Visual Studio 2013 as our IDE. I submitted mine with the follow feedback from him:

"Do not use

Error 1 error C1083: Cannot open include file: 'stdafx.h': No such file or directory c:\users\professor\desktop\++grading\145\school\ch2_2.cpp 5 1 Grading

--------------------

Error 1 error C2061: syntax error : identifier '_TCHAR' c:\users\professor\desktop\++grading\145\school\ch2_2.cpp 13 1 Grading

2 IntelliSense: identifier "_TCHAR" is undefined c:\Users\Professor\Desktop\++Grading\145\school\CH2_2.cpp 13 22 Grading

--------------------------

_TCHAR* is not ANSI standard.nor is _tmain.

------------------

I was able to open your files but not run them."

Literally have no idea what he is asking. I sent him a reply and he's ignored me for the last few days. Feels bad..

My code can be found :

http://collabedit.com/eur2h
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 5 2017 03:13pm
Your problem is the IDE enforces some non standards that are installed along with the IDE for having extra features. As such STDAFX is not part of the standard.

Stdafx is Windows way in trying to fix the long known problem of compiling taking a long time. Especially when compiling against a API as large as windows. What the file is supposed to do is house all your headers and then be solely included in each file. This changes how the compiler compiles the application almost caching the headers to be re-used in future compilations.

Tmain and tchar are also specifics to different standards. For example tchar was more of a windows way to attempt to provide fluent unicode support since the compiler via ifdefs will change the type of tchar to a wide char (2 bytes long allowing for unicode characters), or to type char (1 byte long) depending on the evaluation of the ifdef which looks for a define of UNICODE to know if the system supports unicode.

My suggestion is to install code::blocks and use mingw as your professor seems to be expecting pure C as per the standards, which standard I have no idea since there are many. For example there are minute differences between normal C and c99 (if I recall) where you can not declare variables inside of for loop declarations and the like.

To fix your code to his liking, do the following changes:

-Remove #include "stdafx.h" since you are not using it.
-Rename _tmain to main
-Rename _TCHAR to char

I suggest simply changing compilers and IDEs to avoid future frustrations.

This post was edited by AbDuCt on Feb 5 2017 03:15pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll