user145959 user145959 - 6 months ago 53
C Question

What does this function input means in C language: MODELDIR "/en-us/en-us"

I read the following code from the PocketSphinx tutorial

config = cmd_ln_init(NULL, ps_args(), TRUE,
"-hmm", MODELDIR "/en-us/en-us",
"-lm", MODELDIR "/en-us/en-us.lm.bin",
"-dict", MODELDIR "/en-us/cmudict-en-us.dict",

It's first time I see a variable--
--beside a string--
. How is this possible? I've never seen anything like this in C/C++ tutorial books!

If I want to search for more information about this, what keywords should I use for search?

Answer Source

MODELDIR is a macro expanding to a string. C joins adjacent strings into single ones*, so if MODELDIR would be #defined to "/foo/bar", this would result in the following function call:

config = cmd_ln_init(NULL, ps_args(), TRUE,
             "-hmm", "/foo/bar/en-us/en-us",
                 "-lm", "/foo/bar/en-us/en-us.lm.bin",
                 "-dict", "/foo/bar/en-us/cmudict-en-us.dict",

*) So, writing

"Hello, " "World!"

is exactly the same as

"Hello, World!"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download