Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Function header files

Reply
Thread Tools

Function header files

 
 
Malcolm McLean
Guest
Posts: n/a
 
      02-16-2011
On Feb 16, 2:00*pm, Ralph Spitzner <(E-Mail Removed)> wrote:
> jacob navia wrote:
> > #include <conio.h>

>
> "conio.h is a C header file used in old MS-DOS compilers to create text
> user interfaces. It is not described in The C Programming Language book,
> and it is not part of the C standard library, ISO C nor is it required
> by POSIX."
>
> Sorry don't take seriously, just couldn't resist
>
> * * * * -rasp
>

He's got malloc.h in there as well, which is another DOS-ism.

 
Reply With Quote
 
 
 
 
Ben Bacarisse
Guest
Posts: n/a
 
      02-16-2011
Malcolm McLean <(E-Mail Removed)> writes:

> On Feb 16, 2:04Â*am, alanxx <(E-Mail Removed)> wrote:
>> I am a student of C/C++. One of the mistakes I often make is
>> forgetting to include the appropriate header files for the standard
>> functions I use.
>>

> If it does input/output stdio.h.


There are a lot of IO function not declared there. wchar.h declares all
the "wide" IO functions.

> If it's a trivial function that works
> on a string or area of memory, string.h.


Except for those that operate on wide or multi-byte strings.

> If it's a mathematical
> function, math.h.


Except for the type generic maths functions declared in tgmath.h and all
the complex mathematical functions declared in complex.h.

> If it's malloc() and family or anything else,
> stdlib.h. Major exceptions - ctype.h contains [the] is... macros.


And wctype.h declares the isw... functions. By the way, what you call
the is... macros must be functions, though they can be macros as well.

> assert.h has its own header for some reason. So does time.h.


And there is also stdint.h, inttypes.h, bool.h, complex.h, float.h,
errno.h, setjmp.h, signal.h, stdarg.h, locale.h and fenv.h (and that's
not all of them).

> It's a reasonably logical division, though with a few quirks.


Unfortunately the logic requires some knowledge of the history. For
example the wide IO and string functions are separate because they are
new.

My point is not to enumerate the errors in your classification but to
show that your general point -- which seems to be that it's not too hard
to remember -- is not really true anymore.

--
Ben.
 
Reply With Quote
 
 
 
 
ImpalerCore
Guest
Posts: n/a
 
      02-16-2011
On Feb 15, 7:04*pm, alanxx <(E-Mail Removed)> wrote:
> Hi,
>
> I am a student of C/C++. One of the mistakes I often make is forgetting to include the appropriate header files for the standard functions I use. Is there an easy way (a website?) to find out where a certain standard function is prototyped in? I can find answers via google search or MSDN library, but it's more time consuming than I'd prefer. Ideally, I would prefer to just go to a website, type in the name of the function in a search box and find out what header file I should include and how it is defined. Thanks for your help!
>
> alanxx


The cplusplus.com website might be what you're looking for. If you
type in a function name in the search box, you get a web page of the
function plus its header on the navigation bar to the left.

Hope it helps.
John D.
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      02-16-2011
Le 16/02/11 13:00, Ralph Spitzner a écrit :
> jacob navia wrote:
>> #include <conio.h>

>
> "conio.h is a C header file used in old MS-DOS compilers to create text
> user interfaces. It is not described in The C Programming Language book,
> and it is not part of the C standard library, ISO C nor is it required
> by POSIX."
>
> Sorry don't take seriously, just couldn't resist
>
>
> -rasp
>
>


conio.h describes the interface for old Dos functions in lcc-win that
allows you to use the old Borland "gotoxy()" text mode packages and
have text mode with colors and simple "graphics" using special
characters.

If you do not like it you just erase that line. The concept is clear.

 
Reply With Quote
 
Ralph Spitzner
Guest
Posts: n/a
 
      02-16-2011
jacob navia wrote:
> Le 16/02/11 13:00, Ralph Spitzner a écrit :
>>
>> Sorry don't take seriously, just couldn't resist

^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> If you do not like it you just erase that line. The concept is clear.
>



Not flaming you here. I just thought of it as being 'funny' finding such
a dinosaur, looking at all the C99 etc. discussion going on here.

-rasp

 
Reply With Quote
 
Tom St Denis
Guest
Posts: n/a
 
      02-16-2011
On Feb 16, 9:47*am, jacob navia <(E-Mail Removed)> wrote:
> Le 16/02/11 13:00, Ralph Spitzner a écrit :
>
> > jacob navia wrote:
> >> #include <conio.h>

>
> > "conio.h is a C header file used in old MS-DOS compilers to create text
> > user interfaces. It is not described in The C Programming Language book,
> > and it is not part of the C standard library, ISO C nor is it required
> > by POSIX."

>
> > Sorry don't take seriously, just couldn't resist

>
> > -rasp

>
> conio.h describes the interface for old Dos functions in lcc-win that
> allows you to use the old Borland "gotoxy()" text mode packages and
> have text mode with colors and simple "graphics" using special
> characters.
>
> If you do not like it you just erase that line. The concept is clear.


Along the lines you're talking about it's not uncommon to write a
"project.h" file which includes the relevant header files for the
project. I wouldn't just blindly include all of the headers from /usr/
include mostly because they're not all compatible but also it DOES add
to compile times (hint: think of builds over NFS).

Tom
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      02-16-2011
jacob navia <(E-Mail Removed)> writes:
> Le 16/02/11 13:00, Ralph Spitzner a ecrit :
>> jacob navia wrote:
>>> #include <conio.h>

>> "conio.h is a C header file used in old MS-DOS compilers to create text
>> user interfaces. It is not described in The C Programming Language book,
>> and it is not part of the C standard library, ISO C nor is it required
>> by POSIX."
>>
>> Sorry don't take seriously, just couldn't resist

>
> conio.h describes the interface for old Dos functions in lcc-win that
> allows you to use the old Borland "gotoxy()" text mode packages and
> have text mode with colors and simple "graphics" using special
> characters.
>
> If you do not like it you just erase that line. The concept is clear.


Fair enough. I suppose there's a similar story for <process.h>.

But why is <malloc.h> in the list? Does it give you something that
<stdlib.h> doesn't?

If you're going to use that approach, perhaps it would be better to have
"stdheader.h" include just the standard headers; if you're using
features from <conio.h> it might be better to emphasize that by
including it directly in your source file.

(Personally I've never done that kind of thing, and it *feels* like
poor style, but I'm not sure I can articulate why.)

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
David Resnick
Guest
Posts: n/a
 
      02-16-2011
On Feb 16, 11:00*am, Keith Thompson <(E-Mail Removed)> wrote:
> (Personally I've never done that kind of thing, and it *feels* like
> poor style, but I'm not sure I can articulate why.)


I'm not sure it is bad "style", but it can certainly cause performance
issues in a large scale build to access/read/parse all the unneeded
header files, particularly if they aren't on a local filesystem.
Certainly, including unneeded headers that might change (standard
headers
don't much in practice) introduces unneeded dependencies into the
build process.
It is vexing if someone touches a file that shouldn't trigger a
global
rebuild of targets but does.

To OP, I'd personally just learn which standard functions go with
which headers.
May take a while, but the C standard library isn't THAT huge...

-David

 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      02-16-2011
ImpalerCore <(E-Mail Removed)> writes:

> On Feb 15, 7:04Â*pm, alanxx <(E-Mail Removed)> wrote:
>> Hi,
>>
>> I am a student of C/C++. One of the mistakes I often make is
>> forgetting to include the appropriate header files for the standard
>> functions I use. Is there an easy way (a website?) to find out where
>> a certain standard function is prototyped in? I can find answers via
>> google search or MSDN library, but it's more time consuming than I'd
>> prefer. Ideally, I would prefer to just go to a website, type in the
>> name of the function in a search box and find out what header file I
>> should include and how it is defined. Thanks for your help!
>>
>> alanxx

>
> The cplusplus.com website might be what you're looking for. If you
> type in a function name in the search box, you get a web page of the
> function plus its header on the navigation bar to the left.


I'd advise against using this site unless you are working in C++.
It works for common C functions but fails for a lot of newer C99
functions.

--
Ben.
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      02-16-2011
David Resnick <(E-Mail Removed)> writes:
> On Feb 16, 11:00Â*am, Keith Thompson <(E-Mail Removed)> wrote:
>> (Personally I've never done that kind of thing, and it *feels* like
>> poor style, but I'm not sure I can articulate why.)

>
> I'm not sure it is bad "style", but it can certainly cause performance
> issues in a large scale build to access/read/parse all the unneeded
> header files, particularly if they aren't on a local filesystem.
> Certainly, including unneeded headers that might change (standard
> headers don't much in practice) introduces unneeded dependencies into
> the build process. It is vexing if someone touches a file that
> shouldn't trigger a global rebuild of targets but does.


For the truly standard headers (those defined by the language
standard), updates shouldn't be much of an issue -- and if the
standard headers provided by the implementation are updated, you
probably *should* recompile everything.

I suppose there's a corner case where you have a "stdheader.h",
and the implementation is updated piecemeal, so an update that
affects only <math.h> causes an unnecessary rebuild. I don't know
how often that would occur in practice.

> To OP, I'd personally just learn which standard functions go with
> which headers. May take a while, but the C standard library isn't
> THAT huge...


I tend to agree.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Header files with "header.h" or <header.h> ?? mlt C++ 2 01-31-2009 02:54 PM
UNIX header files to Windows header files anand.ba@gmail.com C Programming 3 05-01-2006 03:57 PM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
Header files included in header files John Smith C Programming 18 07-24-2004 04:55 AM
What is better /standard for creating files. a cpp file with header or cpp and seperate file for header DrUg13 C++ 1 02-10-2004 09:20 AM



Advertisments