Non-Standard Header??

Hi, I saw some people said, "Non-standard" in some header file, may I know what does that means?

"That there non-standard, platform-dependent function is found in <conio.h>. Of course, <iostream.h> is non-standard too... "
That means that a program containing such #include line is not a valid C++ program.

Most compilers have what is known as "non-standard language extensions", where some programs that are not valid C++ programs are nonetheless compiled. If you're using a non-standard feature, your program may only be compiled by the compiler (or several compilers) that implement that particular non-standard feature.
Last edited on
That means that a program containing such #include line is not a valid C++ program.


Not quite. It means that the header is not part of the standard library and therefore isn't guaranteed to be available all the time.

You can certainly make a valid C++ program with non-standard headers. And in fact you do so every time you #include your own header.
Thanks...
Is that u mean some compiler like Borland C++ can execute using <conio> but in VSC++, we need <conio.h> for it to works...that means it's a non-standard header?

No, it's a non-standard header because it's not part of the language standard.

C++ guarantees that there are certain headers available. Headers like <iostream>, <cmath>, etc will always be there... it's like they're built-in as a part of the language.

Headers like <conio.h> aren't. Some compilers provide them as a "bonus", but some don't. There is no guarantee. If you write a program that uses them on machine A, then try to compile it on machine B, your code might not compile because the header might not be on machine B.

Here's a list of all (C++03) standard headers. Anything not on this list is nonstandard (although there may have been some new headers for C++11 -- this site is a little out of date in that regard)

http://cplusplus.com/reference/
That means that a program containing such #include line is not a valid C++ program.

Not quite.


True, the correct statement would be "the behavior of a program containing such #include line is implementation-defined"
but that's true even of standard headers.
Still not quite understand about it...Is that means if it's a standard header, 100% all the compiler can run that program if we use standard header?
Is that means if it's a standard header, 100% all the compiler can run that program if we use standard header?


100% of correct C++ compilers (assuming there are no other mistakes in the program). If the compiler fails to include a standard header or fails to implement some other standard feature, you should file a bug report.

On the other hand, if a program includes a non-standard header (or uses other non-standard language extensions) it can only be discussed in terms of implementation, that is, always post compiler name, version, and target platform along with the source code you're discussing. And since most other people have different compilers, you may find it more difficult to find answers online.
Still not quite understand about it...Is that means if it's a standard header, 100% all the compiler can run that program if we use standard header?


You're overthinking it.

There's something called a "language standard". It's a big fat book that outlines the C++ language.... all the rules, all the things the compilers have to do, etc etc. It basically defines everything about C++.

Headers like <iostream> are part of that big book. The book outlines what they need to do and how they are to be used.

Headers like <conio.h> are not part of that book. The book makes no mention of them.


That's all it means. "Standard header" just means that the header is part of the language standard.
Ok...thanks for the explaination...

how about header file and library header...are they the same?
Last edited on
Topic archived. No new replies allowed.