0

Is it possible to check in compile time that the file name in the #line directive matches the actual name of the file being translated?

pmor
  • 5,392
  • 4
  • 17
  • 36
  • Check against what? – stark Nov 24 '20 at 22:39
  • Does this answer your question? [What's the meaning of #line in C language?](https://stackoverflow.com/questions/2216540/whats-the-meaning-of-line-in-c-language) – Yunnosch Nov 24 '20 at 22:42
  • 1
    It seems to me to be a duplicate because I have the impression that your question is based on a misunderstanding of its meaning/mechanism/behaviour. – Yunnosch Nov 24 '20 at 22:43
  • One of the possible misunderstanding being that you might confuse it with https://www.cprogramming.com/reference/preprocessor/__FILE__.html – Yunnosch Nov 24 '20 at 22:47
  • Or with things you see after using `-E` commandline switch. http://tigcc.ticalc.org/doc/comopts.html#SEC4 – Yunnosch Nov 24 '20 at 22:51
  • Succinctly, no — it is not possible to verify at compile time that the file name in the `#line` directive matches the actual file name. Indeed, it is often used to ensure that a different name is presented in any diagnostics when the C code is generated from some other source language. – Jonathan Leffler Nov 25 '20 at 03:14
  • @JonathanLeffler, Then in https://stackoverflow.com/a/30764776/9881330 when Keith Thompson is telling that it `is left as an exercise` it should be interpreted as a joke? – pmor Nov 25 '20 at 22:08
  • @pmor — yes, I think it is best interpreted as a joke. You could consider leaving a comment asking about it, but I'm not sure whether you would get an answer. – Jonathan Leffler Nov 26 '20 at 00:54

0 Answers0