Reputation: 7060
In the past whenever I came across #define it was used like
#define MOD 1000000007
In the case above all instances of MOD in the code was replaced by 1000000007.
I am new to open source development and was looking at several video filters of VLC media player. It has several uses of #define
as-
//example1
#define MSG_LONGTEXT N_( \
"Marquee text to display. " \
"(Available format strings: " \
"Time related: %Y = year, %m = month, %d = day, %H = hour, " \
"%M = minute, %S = second, ... " \
"Meta data related: $a = artist, $b = album, $c = copyright, " \
"$d = description, $e = encoded by, $g = genre, " \
"$l = language, $n = track num, $p = now playing, " \
"$r = rating, $s = subtitles language, $t = title, "\
"$u = url, $A = date, " \
"$B = audio bitrate (in kb/s), $C = chapter," \
"$D = duration, $F = full name with path, $I = title, "\
"$L = time left, " \
"$N = name, $O = audio language, $P = position (in %), $R = rate, " \
"$S = audio sample rate (in kHz), " \
"$T = time, $U = publisher, $V = volume, $_ = new line) ")
//example 2
#define POSY_TEXT N_("Y offset")
//example 3
#define TIMEOUT_LONGTEXT N_("Number of milliseconds the marquee must remain " \
"displayed. Default value is " \
"0 (remains forever).")
can somebody explain these examples with respect to
#define
and software development both or provide some resources?
Upvotes: 0
Views: 562
Reputation: 258618
It's exactly the same, the only addition is that \
marks the continuation of the current line in the next one. It's there for readability reasons.
For example:
#define TIMEOUT_LONGTEXT N_("Number of milliseconds the marquee must remain " \
"displayed. Default value is " \
"0 (remains forever).")
is equivalent to
#define TIMEOUT_LONGTEXT N_("Number of milliseconds the marquee must remain " "displayed. default value is " "0 (remains forever).")
So whenever TIMEOUT_LONGTEXT
appears in the code, the preprocessor will replace it with N_("whatever")
.
Upvotes: 6