S
Spiros Bousbouras
It is indeed quite common for people to refer to libraries
by referring to the header. It is wrong to do so. It is
extremely common for people to be so totally ignorant of
how libraries work and to indeed believe that the header
is the library. How many times have you heard someone
complain "my program won't compile and it complains
about 'undefined function: log', but I included
math.h"? I've lost count of the number of times
I've had to explain it, and I would prefer that more
people understand the very simple idea that the
header is not the library. Too many people confuse
the two. I believe that jackassp does not understand
the distinction. Perhaps I am wrong about that.
You are correct. Perhaps my first post should have been more
explicit, and I ought to have written, "perhaps you are referring
to some third party library named libregex...", since I was not
assuming any reference to SUS.
If your intention was to be helpful to someone who is
inexperienced then a phrase like "perhaps you are referring to
some third party library named libregex..." would be just as
pointless and unhelpful as what you actually wrote. I am
perfectly aware that some times you have to include extra flags
to link with a library yet I thought that
"regex.h is a header, not a library. Very likely you are
referring to libregex, whose API is published in a file
named regex.h"
was just a pedantic remark on the "proper" way to refer to things.
In no way does it lead anyone to think that including the header
may not be enough. A genuinely helpful remark would be something
like
"Note that the header (regex.h in this case) is not the
library. To see why the distinction is important look at
question 13.25 of the FAQ (http://c-faq.com)"
Note that even such a comment, although it cannot be accused of
pedantry, still runs the danger of offending some people because
it implies that they are beginners.
S N I P
I disagree. Jackassp's post was inaccurate. If he wanted the
OP to use functions from an implementation's libc which are
declared in that implementation's <regex.h>, then he ought
to have written "use functions from regex.h". Or perhaps,
"use libc functions declared in regex.h".
If you refer to "the math.h library", or "the stdio.h library",
or "the regex.h library", you only contribute to confusion.
I agree that Jackassp's post was not 100% accurate. But the
difference between 100% accuracy and what he wrote is a pedantic
one. On the other hand I do not agree that Jackassp's post
contributes to any confusion. His intention was simply to
provide a reference to a library which might perform what the OP
wants. His intention was **not** to provide information on how
such a library should be linked. There is nothing in what he
said to suggest that including the header is enough for the
library to be linked properly. It may or may not be enough but
this is a question completely independent from what the OP asked
and what Jackass answered. If anyone were to draw conclusions on
how a library should be linked from what Jackass said then that
person would be simply jumping to conclusions.
I believe this thread is the first time I've ever been accused
of pedantry. I'll accept that I was inaccurate, since I ought
to have explicitly pointed out that the 'libregex' I was referring
to was a purely fictional name for a library that would reasonably
go with a header named 'regex.h', but I don't don't accept
either that I am being pedantic or that my caution is misplaced.
I accept that your motivation was not pedantry but it certainly
came across as pedantry and in any case it offered nothing
towards guiding an inexperienced C programmer on how to link a
library.
If the day ever comes that no newbie programmer is ever
confused about why he needs to add a -lfoo to CFLAGS
when the source code clearly includes foo.h, then I won't
correct someone who refers to the "foo.h library". Until
then, it is necessary to refer to headers as headers, and
libraries as libraries.
Not every post can or should try to address every misconception
some newbie may possibly have. When the purpose is to denote a
library then mentioning the header is adequate (assuming the
header name itself is unambiguous).