decoration decoration
Stories

GROKLAW
When you want to know more...
decoration
For layout only
Home
Archives
Site Map
Search
About Groklaw
Awards
Legal Research
Timelines
ApplevSamsung
ApplevSamsung p.2
ArchiveExplorer
Autozone
Bilski
Cases
Cast: Lawyers
Comes v. MS
Contracts/Documents
Courts
DRM
Gordon v MS
GPL
Grokdoc
HTML How To
IPI v RH
IV v. Google
Legal Docs
Lodsys
MS Litigations
MSvB&N
News Picks
Novell v. MS
Novell-MS Deal
ODF/OOXML
OOXML Appeals
OraclevGoogle
Patents
ProjectMonterey
Psystar
Quote Database
Red Hat v SCO
Salus Book
SCEA v Hotz
SCO Appeals
SCO Bankruptcy
SCO Financials
SCO Overview
SCO v IBM
SCO v Novell
SCO:Soup2Nuts
SCOsource
Sean Daly
Software Patents
Switch to Linux
Transcripts
Unix Books

Gear

Groklaw Gear

Click here to send an email to the editor of this weblog.


You won't find me on Facebook


Donate

Donate Paypal


No Legal Advice

The information on Groklaw is not intended to constitute legal advice. While Mark is a lawyer and he has asked other lawyers and law students to contribute articles, all of these articles are offered to help educate, not to provide specific legal advice. They are not your lawyers.

Here's Groklaw's comments policy.


What's New

STORIES
No new stories

COMMENTS last 48 hrs
No new comments


Sponsors

Hosting:
hosted by ibiblio

On servers donated to ibiblio by AMD.

Webmaster
Trying to explain APIs (and the Wikipedia API page) | 270 comments | Create New Account
Comments belong to whoever posts them. Please notify us of inappropriate comments.
Trying to explain APIs (and the Wikipedia API page)
Authored by: SLi on Saturday, April 21 2012 @ 09:09 AM EDT

Thank you. For some reason, I've had a hard time trying to understand this (but then again, I wouldn't say that my programming skills are at an advanced level, and I've not messed with java all that much, either.)

So what you are saying is that when I "#include" in a .cpp, I am invoking the API dealing with the most basic in/out functions of C++?

Yes, that's definitely correct. The I/O routines and header files (like ) are part of the standard library, and any time you interact with the standard library in any way, you are doing so via an API.

If this is the case, then how can Oracle get away with saying "Java is a language that is free for all to use" and then turn around and say "you're not allowed to use any of the java commands?" What is a language without commands?

Well, you can have C++ (the core language) without the C++ standard library. It's more common with C, but you can find it with C++. Actually there are terms for just such usage in the C and C++ standards: A hosted implementation and a freestanding implementation. Quoting from GCC documentation:

The ISO C standard defines (in clause 4) two classes of conforming implementation. A conforming hosted implementation supports the whole standard including all the library facilities; a conforming freestanding implementation is only required to provide certain library facilities: those in , , , and ; since AMD1, also those in ; and in C99, also those in and . In addition, complex types, added in C99, are not required for freestanding implementations. The standard also defines two environments for programs, a freestanding environment, required of all implementations and which may not have library facilities beyond those required of freestanding implementations, where the handling of program startup and termination are implementation- defined, and a hosted environment, which is not required, in which all the library facilities are provided and startup is through a function int main (void) or int main (int, char *[]). An OS kernel would be a freestanding environment; a program using the facilities of an operating system would normally be in a hosted implementation.

Almost all userspace programs utilize the standard library and therefore require a hosted environment. But, for example, the Linux kernel (written in C) does not use the standard library; it doesn't have, for example, the functions printf() and exit() (what does it mean for a kernel to exit?).

Many embedded devices are also programmed using C, and they are most often freestanding environments. Where should printf() send the printed output if called by a program that runs in, say, your washing machine? See, it doesn't make too much sense.

C++ is a bit less frequently seen in freestanding environments, but it still happens. For example, the Symbian operating system is written in C++. Also the Arduino "open-source electronic prototyping platform" (a device designed for both learning embedded programming and for people with fairly little programming experience, like artists, who nevertheless would like to be able to control some simple hardware like leds in their projects) can be programmed in C++. It's essentially a very inexpensive board with an AVR microcontroller, a led, a serial port and free I/O pins where you can add your own devices to control or purchase one of several add-on "shields", like an "LCD shield", which are designed to plug into the board. Neither of those offer the full standard library, nor would many of the functions in the standard library make sense in such an environment.

[ Reply to This | Parent | # ]

Groklaw © Copyright 2003-2013 Pamela Jones.
All trademarks and copyrights on this page are owned by their respective owners.
Comments are owned by the individual posters.

PJ's articles are licensed under a Creative Commons License. ( Details )