PDA

View Full Version : Compiling error C2061 with stdlib.h



Pinnix
16th September 2014, 14:51
Hallo everyone!
I'm very newbie to Qt, it is my second day...

My scenario is Qt 4.8.4 with Qt Creator 2.5.2, Visual Studio 2010, Windows XP

In my source code STL is used, the STL files are under C:\STL, so I added to .pro file the command:

CONFIG += ../stl
INCLUDEPATH +=../stl

When I try to compile I got an error related with the stdlib.h (C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\stdlib.h)
The error says: "C2061: syntax error : identifier '_CountofType'"

Is this error due to some inconsistency on the scenario mentioned above?
How to solve it?

Thank you very much in advance!!!
Alx

d_stranz
17th September 2014, 19:46
Are you trying to compile code that contains something like this?



#include "stdafx.h"

template < _CountofType, size_t _SizeOfArray>
char (*__countof_helper( _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];


(Which I found simply by googling "_CountofType". You could have done that too and found the solution to your problem).

The template syntax is incorrect. It should read:



#include "stdafx.h"

template < typename _CountofType, size_t _SizeOfArray>
char (*__countof_helper( _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];

ChrisW67
17th September 2014, 21:56
The CONFIG variable is for selecting selecting compiler and project settings en masse, not including or linking individual libraries. For that you use the INCLUDEPATH and LIBS variables.
http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#config

You should be able to use STL with MSVC 2010 without any special configuration at all.