Underscore in fprintf argument

M

mattman

Very new to GNU-Linux C programming, so I'm not as good at finding
answers to things like this as I want to be ... could someone explain
what the underscore is in the following:

fprintf (stderr, _("Try `%s --help' for more information.\n"),
programName);

Is it a preprocessor directive, or am I missing something obvious?
Probably both. This is my first post, so be gentle.
 
P

Peter Nilsson

mattman said:
Very new to GNU-Linux C programming, so I'm not as good at finding
answers to things like this as I want to be ... could someone explain
what the underscore is in the following:

fprintf (stderr, _("Try `%s --help' for more information.\n"),
programName);

Is it a preprocessor directive,
No.

or am I missing something obvious?

It's likely that there is a macro called simply _ defined somewhere
else in the source code, as in...

#define _(x) x /* or something more */

But the best place to ask about Linux/GnuC programming and source
are the linux and Gnu newsgroups.
 
K

Keith Thompson

mattman said:
Very new to GNU-Linux C programming, so I'm not as good at finding
answers to things like this as I want to be ... could someone explain
what the underscore is in the following:

fprintf (stderr, _("Try `%s --help' for more information.\n"),
programName);

Is it a preprocessor directive, or am I missing something obvious?
Probably both. This is my first post, so be gentle.

It's not predefined. A single underscore is just an identifier; the
program, or some library it uses, probably defines it as a function or
macro. (I think it's commonly used by some internationalization
package; _() probably returns a translation of the message.)
 
M

Martin Ambuhl

mattman said:
Very new to GNU-Linux C programming, so I'm not as good at finding
answers to things like this as I want to be ... could someone explain
what the underscore is in the following:

fprintf (stderr, _("Try `%s --help' for more information.\n"),
programName);

Is it a preprocessor directive, or am I missing something obvious?
Probably both. This is my first post, so be gentle.

let's get this out of the way fist: GNU or gcc-specific questions belong
in a GNU or gcc-specific newsgroup.

The answer to your question is to be found in the code, probably in
header files. You will probably find a macro definition for _(x).
 
T

Tommy Reynolds

fprintf (stderr, _("Try `%s --help' for more information.\n"),
programName);

Is it a preprocessor directive, or am I missing something obvious?
Probably both. This is my first post, so be gentle.

Typical idiom used to identify translatable strings for
internationalization (I18N) tools such as "gettext".

Cheers!
 
C

CBFalconer

Martin said:
let's get this out of the way fist: GNU or gcc-specific questions
belong in a GNU or gcc-specific newsgroup.

The answer to your question is to be found in the code, probably in
header files. You will probably find a macro definition for _(x).

He didn't ask a GNU or gcc-specific question. He asked a C
question, and incidentally mentioned what sort of system he was
using and his experience. There is no need to jump down his throat
about it, especially with your fist :)
 
M

Martin Ambuhl

CBFalconer said:
He didn't ask a GNU or gcc-specific question. He asked a C
question, and incidentally mentioned what sort of system he was
using and his experience. There is no need to jump down his throat
about it, especially with your fist :)

I have not trimmed any of the exchange because had I done so, I would
have been charged with hiding parts that support Mr Falconer's claim.
Anyone with the ability to read can plainly see that I did not jump down
the OP's throat, much less with my fist. Mr Falconer has clearly got
his head up his butt.
 
C

CBFalconer

Martin said:
I have not trimmed any of the exchange because had I done so, I would
have been charged with hiding parts that support Mr Falconer's claim.
Anyone with the ability to read can plainly see that I did not jump down
the OP's throat, much less with my fist. Mr Falconer has clearly got
his head up his butt.

See underlined verbiage above, which triggered the whole thing.
You are taking this far too seriously. The OP also appears to be a
reasonable, if uninformed, sort.
 

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,773
Messages
2,569,594
Members
45,114
Latest member
GlucoPremiumReview
Top