Library Functions .... Standard ??

S

santosh

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.
 
I

Ian Collins

santosh said:
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.
 
J

Jaspreet

santosh said:
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
 
K

Keith Thompson

santosh said:
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.
 
T

Tim Prince

santosh said:
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.
 
R

Richard Heathfield

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.
 
R

Richard Heathfield

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.
 
I

Ian Collins

Richard said:
Ian Collins said:




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?
 
A

Alan

Ian said:
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
 
R

Richard Heathfield

Ian Collins said:
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.
 
J

jacob navia

Richard Heathfield a écrit :
Ian Collins said:




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
 
P

Prashant Mahajan

santosh said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top