From: TimePath Date: Wed, 30 Dec 2015 10:18:09 +0000 (+1100) Subject: Log: stringify __LINE__ at compile time X-Git-Tag: xonotic-v0.8.2~1358 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3fbc261b483be2c73f5514c3a938696b6679efc3;p=xonotic%2Fxonotic-data.pk3dir.git Log: stringify __LINE__ at compile time --- diff --git a/qcsrc/Makefile b/qcsrc/Makefile index 3ff138f2c..dac7cb2bd 100644 --- a/qcsrc/Makefile +++ b/qcsrc/Makefile @@ -48,24 +48,24 @@ $(QCCVERSIONFILE): echo This file intentionally left blank. > $@ ../csprogs.dat: client/progs.inc $(QCCVERSIONFILE) - @$(CC) -xc $(QCCDEFS) -DCSQC -E -dM 1>tmp/client_macros.txt -H 2>tmp/client_includes.txt $< $(CC) -xc $(QCCDEFS) -DCSQC -E -MMD -MP -MT $@ -Wall -Wundef -Werror -CC -o tmp/client.qc $< + @$(CC) -xc $(QCCDEFS) -DCSQC -E -dM 1>tmp/client_macros.txt -H 2>tmp/client_includes.txt $< @sed -i 's/^# \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\2)\n#pragma line(\1)/g' tmp/client.qc @echo make[1]: Entering directory \`$(PWD)/client\' cd client && $(QCC) $(QCCFLAGS) -o ../$@ ../tmp/client.qc -include tmp/client.d ../progs.dat: server/progs.inc $(QCCVERSIONFILE) - @$(CC) -xc $(QCCDEFS) -DSVQC -E -dM 1>tmp/server_macros.txt -H 2>tmp/server_includes.txt $< $(CC) -xc $(QCCDEFS) -DSVQC -E -MMD -MP -MT $@ -Wall -Wundef -Werror -CC -o tmp/server.qc $< + @$(CC) -xc $(QCCDEFS) -DSVQC -E -dM 1>tmp/server_macros.txt -H 2>tmp/server_includes.txt $< @sed -i 's/^# \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\2)\n#pragma line(\1)/g' tmp/server.qc @echo make[1]: Entering directory \`$(PWD)/server\' cd server && $(QCC) $(QCCFLAGS) -o ../$@ ../tmp/server.qc -include tmp/server.d ../menu.dat: menu/progs.inc $(QCCVERSIONFILE) - @$(CC) -xc $(QCCDEFS) -DMENUQC -E -dM 1>tmp/menu_macros.txt -H 2>tmp/menu_includes.txt $< $(CC) -xc $(QCCDEFS) -DMENUQC -E -MMD -MP -MT $@ -Wall -Wundef -Werror -CC -o tmp/menu.qc $< + @$(CC) -xc $(QCCDEFS) -DMENUQC -E -dM 1>tmp/menu_macros.txt -H 2>tmp/menu_includes.txt $< @sed -i 's/^# \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\2)\n#pragma line(\1)/g' tmp/menu.qc @echo make[1]: Entering directory \`$(PWD)/menu\' cd menu && $(QCC) $(QCCFLAGS) -o ../$@ ../tmp/menu.qc diff --git a/qcsrc/lib/log.qh b/qcsrc/lib/log.qh index 0a75d3a58..b5e1ecec3 100644 --- a/qcsrc/lib/log.qh +++ b/qcsrc/lib/log.qh @@ -39,7 +39,7 @@ string(string...) strcat0n = #115; #define _LOG(f, level, s) \ MACRO_BEGIN { \ - f(sprintf("^9[::"level "^9] ["__FILE__ "^7:^9%s^7:^9%d] \n^7%s\n", __FUNC__, __LINE__, s)); \ + f(sprintf("^9[::" level "^9] [" __FILE__ "^7:^9%s^7:^9" STR(__LINE__) "] \n^7%s\n", __FUNC__, s)); \ } MACRO_END #define LOG_FATAL(...) _LOG_FATAL(strcat0n(__VA_ARGS__)) diff --git a/qcsrc/lib/macro.qh b/qcsrc/lib/macro.qh index 1301ca4a4..cc4f37b3d 100644 --- a/qcsrc/lib/macro.qh +++ b/qcsrc/lib/macro.qh @@ -13,4 +13,7 @@ #define _CAT(a, b) a ## b #define CAT(a, b) _CAT(a, b) +#define _STR(it) #it +#define STR(it) _STR(it) + #endif