is there a macro symbol for strlen($LINUX_SOURCE_PATH)

Varun Iyer varun_iyer at posteo.net
Wed Sep 4 18:18:17 EDT 2019


On 19/09/04 03:42PM, jim.cromie at gmail.com wrote:
> in the kernel, there are a lot of usages of __FILE__
> 
> this means that there are a lot of copies of fully rooted paths,
> including all the varying ~/src/linux prefixes used by individual builders.

On gcc, `__FILE__` is the path of the file relative to the directory that the
build is run from.

Try something like
 
#include <stdio.h>
#define testing() printf("%s\n", __FILE__)
int main() { testing(); }

and compile it from different directories to replicate this behaviour.

> 
> Id hazard a guess that something like __RELPATH_FILE__
> would work in many cases and perhaps even be more readable
> (by reducing long strings) in the generated output
> 
> Do the macros exist to cobble this together for compile-time ?
> Does it warrant a short name ? either to wrap __FILE__ uses or replace them ?
> 
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



More information about the Kernelnewbies mailing list