Issue Details (XML | Word | Printable)

Key: STDCXX-195
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Martin Sebor
Reporter: Scott (Yu) Zhong
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
C++ Standard Library

[Linux] error on std::putc()

Created: 05/Jun/06 10:22 PM   Updated: 06/Jan/08 11:19 PM
Return to search
Component/s: 27. Input/Output
Affects Version/s: 4.1.3
Fix Version/s: 4.2.1

Time Tracking:
Not Specified

Environment:
SuSE SLES 9sp2 (ppc64), IBM XL C/C++ Advanced Edition V8.0 for Linux
Version: 08.00.0000.0000
Issue Links:
Reference
 

Severity: Compiler Error
Resolution Date: 06/Jan/08 11:19 PM


 Description  « Hide
IBM VAC++ 8.0 linux uses _IO_putc instead of putc

file affected:

include/ansi/cstdio

------- testcase.cpp --------

#include <cstdio>

int main()
{
std::putc ("test", stdout);
std::fflush (stdout);
}

---------- compile line ----------------
xlc -F /package/1/ppc64/compilers/ibm/va80/vac.cfg -q64 -qarch=ppc64 -D_RWSTD_NO_IMPLICIT_INCLUSION -qnolib -Wl,-dynamic-linker -Wl,/lib64/ld64.so.1 -D_RWCONFIG=stdlib_rs -I../../include -I./../../../../include -I./../../../../include/ansi -I./../../../.. -I.. -I. -g -c ../testcase.cpp

---------- output ----------------------
"../testcase.cpp", line 5.9: 1540-0130 (S) "std::_IO_putc" is not declared.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Martin Sebor added a comment - 06/Jun/06 01:54 AM
Scott, I believe I know what you're talking about but it would be good to have a small test case demonstrating the problem.

Martin Sebor added a comment - 06/Jun/06 02:47 AM
This is also an issue when using gcc:

$ cat t.cpp && uname -srvp && gcc -dumpversion && make t
#include <cstdio>

int main()
{
std::putc ('x', stdout);
}
Linux 2.6.5-7.191-pseries64 #1 SMP Tue Jun 28 14:58:56 UTC 2005 ppc64
3.3.3
gcc -c -I/amd/devco/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG -pthread -D_RWSTD_USE_CONFIG -I/amd/devco/sebor/dev/stdlib/include -I/build/sebor/gcc-3.3.3-15S/include -I/amd/devco/sebor/dev/stdlib/examples/include -pedantic -nostdinc++ -g -m64 -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long -Wcast-align t.cpp
t.cpp: In function `int main()':
t.cpp:5: error: `_IO_putc' undeclared in namespace `std'
make: *** [t.o] Error 1


Martin Sebor added a comment - 06/Jun/06 02:53 AM
The problem here is that putc is #defined as a macro by the C library. This is explicitly disallowed by lib.headers, p6 (clarified by Footnote 166):

6 Names that are defined as functions in C shall be defined as functions in the C++ Standard Library.166)
___________
Footnote 166) This disallows the practice, allowed in C, of providing a "masking macro" in addition to the function prototype. The only way to achieve equivalent "inline" behavior in C++ is to provide a definition as an extern inline function.


Martin Sebor added a comment - 04/Jan/08 01:24 AM
See also STDCXX-637 for a similar problem with getwc() and putwc().

Martin Sebor added a comment - 04/Jan/08 01:49 AM
Same problem with getc():

$ cat t.cpp && make t
#include <cstdio>

int main()
{
std::putc ('x', stdout);
std::getc (stdin);
}
gcc -c -I/home/sebor/stdcxx/include/ansi -D_RWSTDDEBUG -pthread -I/home/sebor/stdcxx/include -I/build/sebor/stdcxx-gcc-4.1.2-15D/include -I/home/sebor/stdcxx/examples/include -pedantic -nostdinc++ -g -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long -Wcast-align t.cpp
t.cpp: In function 'int main()':
t.cpp:5: error: '_IO_putc' is not a member of 'std'
t.cpp:6: error: '_IO_getc' is not a member of 'std'
make: *** [t.o] Error 1


Martin Sebor added a comment - 06/Jan/08 11:19 PM
Closing as Fixed.