LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-21-2014, 11:15 AM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
C: stdio.h: where is the source?


Hi: given a C source file that begins
Code:
#include <stdio.h>
Where does the compiler look for the source where the objects declared in stdio.h are defined?
 
Old 01-21-2014, 11:16 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,836

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
that depends on the compiler itself, usually in /usr/include, but it is only the header
the source code of those objects are already compiled and will be linked together with your code.

Last edited by pan64; 01-21-2014 at 11:17 AM.
 
Old 01-21-2014, 11:39 AM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
OK. Let's subtitute usb.h for stdio.h in a sentence like
Code:
#include <usb.h>
In a certain library the functions declared by usb.h are already compiled. Specifically, there is the function usb_control_msg in usb.h. So the sources may come from many places?! As I have in vain looked for complete specifications for the use of that function, I wanted to go to the source. Now I see I was being naive.
 
Old 01-21-2014, 12:05 PM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,836

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
in general you do not need the source, just the documentation.
http://libusb.sourceforge.net/doc/fu...ontrolmsg.html
but sometimes it is not sufficient. In that case you can try to browse the source here:
http://lxr.free-electrons.com/source.../message.c#L81
(but I'm not really sure if it was the same version)
 
1 members found this post helpful.
Old 01-21-2014, 12:10 PM   #5
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
stdio is part of glibc, so the sources for the functions are in the glibc source code.
 
1 members found this post helpful.
Old 01-21-2014, 12:36 PM   #6
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Code:
apt-get source  <pkgname>
should work on Debian-based distros. On redhat you need to look at rpm info to find the source rpm.
 
Old 01-21-2014, 12:55 PM   #7
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Quote:
Originally Posted by pan64 View Post
in general you do not need the source, just the documentation.
http://libusb.sourceforge.net/doc/fu...ontrolmsg.html
but sometimes it is not sufficient. In that case you can try to browse the source here:
http://lxr.free-electrons.com/source.../message.c#L81
(but I'm not really sure if it was the same version)
Yes, the http://libusb.sourceforge.net/doc/fu...ontrolmsg.html is insufficient. And the second link, well I have /usb/core/message.c in my disk already, and the order and quantity of the arguments are different to those declared in /usr/include/usb.h. Doesn't matter, for it would be hard for me to draw safe conclusions form the sources, now I see.

What I need, is something like The GNU C Library.htm, which explains everything in such detail and so much intelligibility. Look at the sourceforge.net link and tell me if you can understand what it is about! And all the pages from Google refer to this kind of documentation.
 
Old 01-21-2014, 04:46 PM   #8
gengisdave
Member
 
Registered: Dec 2013
Location: Turin, Italy
Distribution: slackware
Posts: 328

Rep: Reputation: 74
usb.h comes from libusb package, if you look at the package sources, there is libusb-compat-x.y.z.tar.xz containing usb.h and core.c which contains the implementations from usb.h
 
1 members found this post helpful.
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
stdio.c cigarstub Programming 12 12-19-2014 06:39 AM
What package is stdio.h in? halfpower Linux - Newbie 4 08-25-2005 10:57 AM
gcc and stdio in 9.1 iansworld SUSE / openSUSE 1 10-19-2004 01:35 PM
#include <stdio.h>? blackzone Programming 2 09-30-2004 06:00 AM
input from stdio raven Programming 2 05-12-2002 10:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration