0

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?

1
  • These don't take any parameters. They replace themselves with N_(some string), N_ is probably some text handling macro similar to the WinAPI's TEXT Commented Sep 18, 2012 at 18:01

1 Answer 1

6

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").

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.