include or project setting in msvc for uint8_t and similar types? - c++

When I create a new msvc project and try using the type uint8_t I get the following compile error:
error C2065: 'uint8_t' : undeclared identifier
Is there a project setting or predefined include that I can use? I'd prefer not to typedef values explicitly.

You need to include <stdint.h> (or <cstdint>), which is not available prior to VS2k10 as far as I can tell.
If you're using an older version of cl you can search for an open source implementation that meets your licensing requirements, or if none exist you'll have to supply the typedefs yourself.

Boost library have some definitions for this. But it's only for C++.

Related

xCode C++: no type named 'return_temporary_buffer' in namespace std

I'm trying to build a C++ OpenGL application in xCode 6.1.1 on OSX 10.9.5 for a Mac version of a game I'm writing. I've managed to achieve this before with prior versions of xCode (and presumably GCC) but I'm really struggling to get it to build.
I created the project as a Command Line Tool and added the required files and preprocessor macros to select the appropriate libraries but I'm getting compile errors with regards to standard libraries.
If I use libc++ (LLVM C++ standard library) I get errors in algorithm such as:
Use of undeclared identifier of 'numeric_limits'
No member named 'digits' in the global namespace
No member named 'max' in the global namespace; did you mean simply 'max'?
Use of undeclared identifier 'uint32_t'
If I use libstdc++ (GNU C++ standard library) I get significantly less errors:
stl_bvector.h: Use of undeclared identifier 'CHAR_BIT'
stl_tempbuf.h:
No type named 'return_temporary_buffer' in namespace 'std' (x2)
No template named 'get_temporary_buffer'; did you mean '::std::_Temporary_buffer'?
Too few template arguments for class template '_Temporary_buffer'
So it seems the STD libraries have got screwed up but I don't understand how and if that is the case, why hasn't this been reported more? So I'm assuming I must be doing something wrong but I can't work out why...

Building C++ application for eCos on ARM

I'm looking to build a C++ application for eCos on an ARM processor. My program requires several standard C++ header files such as vector, iostream, list, ...
My question is: how can I achieve this? Does anyone have any experience building and deploying C++ applications for eCos?
When I use the arm-eabi-g++ compiler to compile the application, I get the following error
fatal error: vector: No such file or directory
meaning that the C++ vector library is not present.
However, the arm-none-eabi-g++ compiler does include these standard header files. I do get the following errors for '':
In file included from /opt/arm-2010.09/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/include/c++/4.5.1/bits/locale_facets.h:43:0,
from /opt/arm-2010.09/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/include/c++/4.5.1/bits/basic_ios.h:39,
from /opt/arm-2010.09/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/include/c++/4.5.1/ios:45,
from /opt/arm-2010.09/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/include/c++/4.5.1/ostream:40,
from /opt/arm-2010.09/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/include/c++/4.5.1/iostream:40,
/opt/arm-2010.09/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/include/c++/4.5.1/arm-none-eabi/bits/ctype_base.h:44:35: error: '_U' was not declared in this scope
/opt/arm-2010.09/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/include/c++/4.5.1/arm-none-eabi/bits/ctype_base.h:45:32: error: '_L' was not declared in this scope
/opt/arm-2010.09/bin/../lib/gcc/arm-none-eabi/4.5.1/../../../../arm-none-eabi/include/c++/4.5.1/arm-none-eabi/bits/ctype_base.h:46:32: error: '_U' was not declared in this scope
...
Can I use the arm-none-eabi-g++ compiler for eCos? If yes, how do I solve these errors? If no, what should I do?
Many thanks in advance!
vector, list, they are basically belong to Standard template library. For ecos there might be something similar available likewise BOOST.
I think u can check this link
You need ustl. See Using uSTL in eCos applications.
Here's a short example for using vector.
You must include
#include <ustl.h>
Then you may instantiate a vector like so:
ustl::vector<int> v(2);

c++ build error

I am trying to integrate wwise into a test project. I have a project on windows 7 using ms visual studio 2010 and this is the error I get after I try and add a necassary cpp to the project. i dont get this build error on my machine at home with the same set up, what does it mean?
------ Build started: Project: wwise test, Configuration: Debug Win32 ------
AkFilePackageLUT.cpp
c:\program files (x86)\audiokinetic\wwise v2012.2.1 build 4427\sdk\samples\soundengine\common\akfilepackagelut.h(204): error C2065: 'NULL' : undeclared identifier
c:\program files (x86)\audiokinetic\wwise v2012.2.1 build 4427\sdk\samples\soundengine\common\akfilepackagelut.cpp(117) : see reference to function template instantiation 'const CAkFilePackageLUT::AkFileEntry<T_FILEID> *CAkFilePackageLUT::LookupFile<AkFileID>(T_FILEID,const CAkFilePackageLUT::FileLUT<T_FILEID> *,bool)' being compiled
with
[
T_FILEID=AkFileID
]
c:\program files (x86)\audiokinetic\wwise v2012.2.1 build 4427\sdk\samples\soundengine\common\akfilepackagelut.h(204): error C2065: 'NULL' : undeclared identifier
c:\program files (x86)\audiokinetic\wwise v2012.2.1 build 4427\sdk\samples\soundengine\common\akfilepackagelut.cpp(140) : see reference to function template instantiation 'const CAkFilePackageLUT::AkFileEntry<T_FILEID> *CAkFilePackageLUT::LookupFile<AkUInt64>(T_FILEID,const CAkFilePackageLUT::FileLUT<T_FILEID> *,bool)' being compiled
with
[
T_FILEID=AkUInt64
]
To me it looks on the first glance like you did not specify a template parameter .
Other possible causes:
You are compiling with a debug version of the C runtime, declaring a
Standard C++ Library iterator variable in a for loop, and then
trying to use that iterator variable outside the scope of the for
loop. Compiling Standard C++ Library code with a debug version of
the C runtime implies /Zc:forScope. See Debug Iterator Support for
more information.
You may be calling a function in an SDK header file that is
currently not supported in your build environment.
Omitting necessary include files, especially if you define
VC_EXTRALEAN, WIN32_LEAN_AND_MEAN, or WIN32_EXTRA_LEAN. These
symbols exclude some header files from windows.h and afxv_w32.h to
speed compiles. (Look in windows.h and afxv_w32.h for an up-to-date
description of what's excluded.)
Identifier name is misspelled.
Identifier uses the wrong uppercase and lowercase letters.
Missing closing quote after a string constant.
Improper namespace scope. To resolve ANSI C++ Standard Library
functions and operators, for example, you must specify the std
namespace with the using directive. The following example fails to
compile because the using directive is commented out and cout is
defined in the std namespace
This error message is saying the following:
in <path...>\akfilepackagelut.h there is a definition of a function template. In fact, it is a templated method of a class. Inside that definition, on line 204, the name NULL is used. NULL is defined in header <cstddef> of the C standard library, and normally you can include that definition by including one of a lot of C/C++ headers, because most of them somehow include <cstddef>. However, akfilepackagelut.h seems to include only headers that in the VS2012 installation you are using do not include that definition, so the compiler does not know what NULL means.
The whole rest of the error message is just template error gibberish, telling you that that function template we are talking about has been instantiated twice somewhere in AkFilePackageLUT.cpp, telling you the exact locations and the template parameters and so on.
What can you do?
Well, if you can not modify the source as you say (Why? You have the source) you can't do anything but perhaps file a bug for the project. If you can modify it would be best to #include <cstddef> in akfilepackagelut.h.

iphlpapi / ifdef.h

I'm trying to use iphlpapi (GetAdapterInfo) and am having trouble compiling the code. I have iphlpapi.h from SDK 7 and have added the appropriate path to the include files in visual studio.
I get the following error...
c:\program files\microsoft sdks\windows\v7.0\include\ifdef.h(154) : error C2146: syntax error : missing ';' before identifier 'NET_IFTYPE'
The lines in ifdef where this occurs are shown below.
typedef NET_LUID IF_LUID, *PIF_LUID;
typedef ULONG NET_IFINDEX, *PNET_IFINDEX; // Interface Index (ifIndex)
typedef UINT16 NET_IFTYPE, *PNET_IFTYPE; // Interface Type (IANA ifType)
I finally figured out how to get this to work so I'm putting this here for others who might stumble upon it.
First, I'm using visual c++ version 6.0 with the 2003 sdk. I added the sdk as the first choice using TOOLS->OPTIONS->DIRECTORIES. Adding the include winsock2.h caused about 60 redefinition errors. I found several sources telling me that the winsock2 include had to precede the windows.h include. My windows.h include was generated for me by VC++ in the precompiled header stdafx.h so I moved the winsock2.h include there. I now can compile and run my program!
According to this page, it looks as though you might need to make sure winsock2.h is included first. I'm guessing that it defines some of those types.
Also, the MSDN page for NET_LUID says it requires Vista at a minimum. Make sure that's true.

C++ Compiler Error C2371 - Redefinition of WCHAR

I am getting C++ Compiler error C2371 when I include a header file that itself includes odbcss.h. My project is set to MBCS.
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\odbcss.h(430) :
error C2371: 'WCHAR' : redefinition; different basic types 1>
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winnt.h(289) :
see declaration of 'WCHAR'
I don't see any defines in odbcss.h that I could set to avoid this. Has anyone else seen this?
This is a known bug - see the Microsoft Connect website:
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=98699
The error doesn't occur if you compile your app as Unicode instead of MBCS.
There are a half-dozen posts on various forums around the web about this - it seems to potentially be an issue when odbcss.h is used in the presence of MFC. Most of the answers involve changing the order of included headers (voodoo debugging). The header that includes odbcss.h compiles fine in it's native project, but when it is included in a different project, it gives this error. We even put it in the latter project's stdafx.h, right after the base include for MFC, and still no joy. We finally worked around it by moving it into a cpp file in the original project, which does not use MFC (which should have been done anyway - but it wasn't our code). So we've got a work-around, but no real solution.
This error happens when you redeclare a variable of the same name as a variable that has already been declared. Have you looked to see if odbcss.h has declared a variable you already have?
does this help?
http://bytes.com/forum/thread602063.html
Content from the thread:
Bruno van Dooren [MVP VC++] but i know the solution of this problem.
it solves by changing project setting of "Treat wchar_t as Built-in
Type" value "No (/Zc:wchar_t-)". But I am using "Xtreme Toolkit
Professional Edition" for making good look & Feel of an application,
when i fix the above problem by changing project settings a new
linking errors come from Xtreme Toolkit Library. So what i do to fix
this problem, in project setting "Treat wchar_t as Built-in Type"
value "yes" and i wrote following statements where i included wab.h
header file. You can change that setting on a per-codefile basis so
that only specific files are compiled with that particular setting. If
you can solve your problems that way it would be the cleanest
solution.
#define WIN16
#include "wab.h"
#undef WIN16
and after that my project is working fine and all the things related to WAB is also working fine. any one guide me, is that the right way
to solve this problem??? and, will this have any effect on the rest of
project?? I wouldn't worry about it. whatever the definition, it is a
16 bit variable in both cases. I agree that it isn't the best looking
solution, but it should work IF WIN16 has no other impact inside the
wab.h file.
--
Kind regards, Bruno van Dooren bruno_nos_pam_van_dooren#hotmail.com
Remove only "_nos_pam"