IBM Support

wchar_t definition not found when stdio.h is included

Troubleshooting


Problem

On SLES10, the definition of the typedef "wchar_t" can be found by including stdio.h. But on SLES11, this has been corrected. "wchar_t" is now defined in wchar.h.

Symptom

When you port programs that include <stdio.h> from SLES10 to SLES11, you might get an "undeclared identifier wchar_t" error.

Consider the following example:

#include <stdio.h>

int main()
{
   wchar_t in_elem;
   return 55;
}

Use the following command to compile the program with XL C/C++ for Linux, V10.1 on SLES10:

$xlc t.c



The program is compiled successfully.

However, if you compile the program with the same compiler on SLES11, you get the following error messages:

"t.c", line 5.13: 1506-275 (S) Unexpected text in_elem encountered.


"t.c", line 5.5: 1506-045 (S) Undeclared identifier wchar_t.

Resolving The Problem

To use "wchar_t" in programs on SLES11, include <wchar.h>. This change takes effect on SLES11(http://sources.redhat.com/ml/libc-hacker/2007-07/msg00025.html).

Consider the following example:

#include <wchar.h>

int main()
{
   wchar_t in_elem;
   return 55;
}

Use the following command to compile the program with XL C/C++ for Linux, V10.1 on SLES11:

$xlc t.c



The program is compiled successfully.

[{"Product":{"code":"SSXVZZ","label":"XL C\/C++ for Linux"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Compiler","Platform":[{"code":"PF016","label":"Linux"}],"Version":"10.1","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
08 August 2018

UID

swg21432894