#define C用法,取多个值

时间:2012-09-18 17:57:20

标签: c open-source c-preprocessor

过去每当我遇到#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

和软件开发兼并或提供一些资源?

1 个答案:

答案 0 :(得分: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")