0

过去,每当我遇到#define 时,它​​都被用作

#define MOD 1000000007

在上述情况下,代码中的所有 MOD 实例都被替换为 1000000007。
我是开源开发的新手,正在研究 VLC 媒体播放器的几个视频过滤器。它有多种用途#define——

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

有人可以解释这些例子吗

#define

和软件开发两者还是提供一些资源?

4

1 回答 1

6

完全一样,唯一的补充就是\在下一行中标记了当前行的延续。出于可读性的原因,它在那里。

例如:

 #define TIMEOUT_LONGTEXT N_("Number of milliseconds the marquee must remain " \
                         "displayed. Default value is " \
                         "0 (remains forever).")

相当于

 #define TIMEOUT_LONGTEXT N_("Number of milliseconds the marquee must remain " "displayed. default value is " "0 (remains forever).")

因此,只要TIMEOUT_LONGTEXT出现在代码中,预处理器就会将其替换为N_("whatever").

于 2012-09-18T18:00:06.477 回答