I am using a function pointer variable named as "stream. SO i think it might create errors if it is a reserved keyword in c or c++. Thanks in advance.
-
3Wouldn't it be faster to try yourself? – Manlio Jul 28 '11 at 11:00
-
1I am sure the compiler will tell you this quite happily. – driis Jul 28 '11 at 11:01
-
1You're absolutely correct - it _will_ create an error if it is a reserved word :-) – paxdiablo Jul 28 '11 at 11:07
-
Wrong guys. Assuming a compiler will tell you gets people into trouble every day. – Bernd Elkemann Jul 28 '11 at 11:09
-
-1. how hard is it to google for "reserved keyword c c++"? – David Rodríguez - dribeas Jul 28 '11 at 12:30
-
1A PDF of the C Standard (a draft of it) is [freely available online](http://www.open-std.org/JTC1/sc22/wg14/www/docs/n1256.pdf). – pmg Jul 28 '11 at 15:02
-
http://cs.smu.ca/~porter/csc/ref/cpp_keywords.html – ascanio Jul 28 '11 at 11:02
2 Answers
No, stream
is not a keyword in either C or C++. See the accepted answer to Why is "array" marked as a reserved word in Visual-C++?
However, as pointed out by @pmg, this is not the whole story. Identifiers starting with str
followed by a lowercase letter are reserved by the C standard for additional string functions. The gcc
manual provides a handy list of identifiers to be avoided.
-
6
-
-1 `array` and `stream` are different: the first is available for any use; the 2nd is reserved by the C Standard. – pmg Jul 28 '11 at 15:00
-
As other answers say stream is not a keyword.
However it IS technically a reserved identifier - all identifiers starting with str followed by a lower case letter are reserved for future additions to string.h
So in theory there's a possibility that a future version of C could introduce a standard function called stream and thus break your code. However the actual chance of that happening is probably tiny.

- 1,270
- 9
- 13
-
+1 The only correct answer so far: `printf` also is not a keyword and you really shouldn't use it for your own identifiers. – pmg Jul 28 '11 at 14:55