By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,902 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Library Functions .... Standard ??

P: n/a
Library Functions provided by the compiler, are they portable?
i.e. is there any ANCI C standards for these functions.

eg. getch() function defined in <conio.h> header file works fine in
windows C compiler but gcc compiler in linux does not recognise it.

gcc compiler does not define <conio.h> header file.

Apr 21 '06 #1
Share this Question
Share on Google+
11 Replies


P: n/a
santosh wrote:
Library Functions provided by the compiler, are they portable?
i.e. is there any ANCI C standards for these functions.

eg. getch() function defined in <conio.h> header file works fine in
windows C compiler but gcc compiler in linux does not recognise it.

gcc compiler does not define <conio.h> header file.

If you stick with the standard C library as specified in the C standard,
your code will be portable.

gcc doesn't provide <conio.h>, Windows does.

--
Ian Collins.
Apr 21 '06 #2

P: n/a

santosh wrote:
Library Functions provided by the compiler, are they portable?
Not all. There may be some functions specific to your compiler like
getch() which you have pointe dout below.
i.e. is there any ANCI C standards for these functions.

eg. getch() function defined in <conio.h> header file works fine in
windows C compiler but gcc compiler in linux does not recognise it.

gcc compiler does not define <conio.h> header file.


http://www-ccs.ucsd.edu/c/lib_over.html

Apr 21 '06 #3

P: n/a
"santosh" <sa***********@gmail.com> writes:
Library Functions provided by the compiler, are they portable?
i.e. is there any ANCI C standards for these functions.
Some are standard, some aren't. Search for "n1124.pdf" to see the
most current draft of the standard; section 7 defines the standard
library. Implementations typically provide additional functions.
(Ideally your documentation should tell you which functions are
standard and which ones are not.)
eg. getch() function defined in <conio.h> header file works fine in
windows C compiler but gcc compiler in linux does not recognise it.

gcc compiler does not define <conio.h> header file.


Neither getch() nor <conio.h> is defined by the C standard.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Apr 21 '06 #4

P: n/a
santosh wrote:
Library Functions provided by the compiler, are they portable?
i.e. is there any ANCI C standards for these functions.

eg. getch() function defined in <conio.h> header file works fine in
windows C compiler but gcc compiler in linux does not recognise it.

gcc compiler does not define <conio.h> header file.

No, there is no standard on the contents of headers provided by the
compiler, which are not described by the standard. Nor is there any
standard which says a gcc installation, on Windows or elsewhere, should
define such functions in the same named header file as a compiler you
associate more closely with a certain operating system.
gcc itself is parsimonious about providing headers not defined in the
standard. Quite likely, a header and library for a nonstandard function
like this is optional and can be installed or not, as you choose.
Apr 21 '06 #5

P: n/a
santosh said:
Library Functions provided by the compiler, are they portable?
Not all of them, no.
i.e. is there any ANCI C standards for these functions.
You mean ANSI? Well, all the ones that are defined by ANSI are portable
across all hosted implementations, and so *must* be provided by the
implementation.
eg. getch() function defined in <conio.h> header file works fine in
windows C compiler but gcc compiler in linux does not recognise it.
It would if you added #include <curses.h> BUT it wouldn't be the same
getch(). It doesn't do the same job. That's one slightly less obvious snag
with non-portable functions such as getch().
gcc compiler does not define <conio.h> header file.


Right.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Apr 21 '06 #6

P: n/a
Ian Collins said:
gcc doesn't provide <conio.h>, Windows does.


Not true. It is supplied by some implementations, not by the OS. In any
case, it pre-dates Windows.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Apr 21 '06 #7

P: n/a
Richard Heathfield wrote:
Ian Collins said:

gcc doesn't provide <conio.h>, Windows does.

Not true. It is supplied by some implementations, not by the OS. In any
case, it pre-dates Windows.

OK, half true - gcc doesn't provide it :)

If rusty grey cells can be trusted, I think it was a DOS header?

--
Ian Collins.
Apr 21 '06 #8

P: n/a
Ian Collins wrote:
Richard Heathfield wrote:
Ian Collins said:

gcc doesn't provide <conio.h>, Windows does.

Not true. It is supplied by some implementations, not by the OS. In any
case, it pre-dates Windows.

OK, half true - gcc doesn't provide it :)

If rusty grey cells can be trusted, I think it was a DOS header?


It was in Turbo C 1.0 & 2.0 and Borland C++ version 3.1. Used to provide
"windowing" functions in DOS or in a DOS box under Windows. Provided
things like gotoXY(), TextColor(), TextBackground(), window() and so on.

As far as I know that was the only place conio.h existed

Alan

Apr 21 '06 #9

P: n/a
Ian Collins said:
Richard Heathfield wrote:
Ian Collins said:

gcc doesn't provide <conio.h>, Windows does.

Not true. It is supplied by some implementations, not by the OS. In any
case, it pre-dates Windows.

OK, half true - gcc doesn't provide it :)

If rusty grey cells can be trusted, I think it was a DOS header?


Not so. It is supplied by some implementations, not by the OS.

Borland provided a conio.h header in Turbo C. So, I believe, did Microsoft
in their own (cough) implementation - but with different contents. DJGPP
also provides one which consciously emulates Borland's.

And Zog C provides one too. See the following URL:

http://dspace.dial.pipex.com/town/green/gfd34/art/

Click on Software link when you get there - don't worry, it's just passive
HTML.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Apr 21 '06 #10

P: n/a
Richard Heathfield a écrit :
Ian Collins said:

Richard Heathfield wrote:
Ian Collins said:

gcc doesn't provide <conio.h>, Windows does.
Not true. It is supplied by some implementations, not by the OS. In any
case, it pre-dates Windows.


OK, half true - gcc doesn't provide it :)

If rusty grey cells can be trusted, I think it was a DOS header?

Not so. It is supplied by some implementations, not by the OS.

Borland provided a conio.h header in Turbo C. So, I believe, did Microsoft
in their own (cough) implementation - but with different contents. DJGPP
also provides one which consciously emulates Borland's.

And Zog C provides one too. See the following URL:

http://dspace.dial.pipex.com/town/green/gfd34/art/

Click on Software link when you get there - don't worry, it's just passive
HTML.


Awesome. I think I have to scrap lcc-win32 and buy some Death Stations
with associated compiler.

jacob
Apr 21 '06 #11

P: n/a

santosh wrote:
Library Functions provided by the compiler, are they portable?
i.e. is there any ANCI C standards for these functions.

eg. getch() function defined in <conio.h> header file works fine in
<conio.h> or Console Input/Output header is normally found in Windows
based C Compilers. But, frankly it has nothing to do with any OS, maybe
in the near future a header by the name "<conio.h>" might get shipped
with Linux based C Compliers. But still till date it doesn't come under
the standerd C.
windows C compiler but gcc compiler in linux does not recognise it.

For your information gcc implementation can be found for Windows as
well.

Apr 21 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.