- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please take a look at a Test-Case ( MFC Collections are used ):
...
CMapStringToString mS2S;
...
CString csKey = "";
CString csKeyValue = "";
...
POSITION pos = mS2S.GetStartPosition();
while( pos != NULL )
{
mS2S.GetNextAssoc( pos, csKey, csKeyValue );
printf( "\\tKey: %s\\tKey Value: %s\\n", csKey, csKeyValue );
}
...
../Common/PrtTests.cpp(28816): warning #1595: non-POD (Plain Old Data) class type passed through ellipsis
printf( "\\tKey: %s\\tKey Value: %s\\n", csKey, csKeyValue );
^
My questions are: What is 'non-POD'? What is wrong?
Development Environment:
OS: Windows XP 32-bit
IDE: Visual Studio 2005 SP1
Compilers: Intel C++ / Microsoft C++ / Borland C++ / MinGW / Turbo C++
Best regards,
Sergey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In section 5.2.2, paragraph 7, the C++ Standard says that it's undefined to pass objects of non-POD class types to the ellipsis. VC++ does not emit a diagnostic for this, and code such as the following compiles cleanly. This particular example produces several random characters in its output, while others may crash or malfunction in more subtle ways.
#include
#include
int main()
{
std::string s = "test";
printf("Without c_str(): %s\n", s);
}
A "POD" type is defined here:
http://stackoverflow.com/questions/146452/what-are-pod-types-in-c
Judy
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The POD is plane old data type object, eg int, float, double. It would be nice if you can provide complte test case to reproduce the issue. I could not reproduce the issue using the folloing test case.
c:\forum\U105042>type tst.cpp
// tst.cpp
#include
#include
int main()
{
CString csKey = "";
CString csKeyValue = "";
printf("\tKey: %s\tKey Value: %s\n", csKey, csKeyValue );
return 0;
}
c:\forum\U105042>icl tst.cpp
Intel C++ Compiler XE for applications running on IA-32, Version 12.1.1.258 Build 20111011
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
tst.cpp
_WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
Microsoft Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
-out:tst.exe
tst.obj
c:\forum\U105042>tst
Key: Key Value:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The POD is plane old data type object, eg int, float, double. It would be nice if you can provide complte test case to reproduce the issue. I could not reproduce the issue using the folloing test case.
...
Your Test-Case is right.
...
c:\forum\U105042>icl tst.cpp
Please try to set a Warning Level 5.
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need topay attention forevery issuebecause a project isdesigned for many platforms, including Embedded.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In section 5.2.2, paragraph 7, the C++ Standard says that it's undefined to pass objects of non-POD class types to the ellipsis. VC++ does not emit a diagnostic for this, and code such as the following compiles cleanly. This particular example produces several random characters in its output, while others may crash or malfunction in more subtle ways.
#include
#include
int main()
{
std::string s = "test";
printf("Without c_str(): %s\n", s);
}
A "POD" type is defined here:
http://stackoverflow.com/questions/146452/what-are-pod-types-in-c
Judy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a C++ operator 'char *'?
Because, if the'string' classwould have it a code:
std::string s = "test";
printf( "Without c_str(): %s\n", s );
would be processed by a C++ compiler to:
std::string s = "test";
printf( "Without c_str(): %s\n", ( char * )s );
and, as you can see, there is noneed touse the'c_str' method.
Best regards,
Sergey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page