- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The name of the current source file is stored by a C/C++ compiler in ANSI-Compliant Predefined macro __FILE__.
How could I control the format? For example:
MinGW stores it as: ../../folder3/test.cpp
Visual C++ compiler stores it as: c:\\folder1\\folder2\\folder3\\test.cpp
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Sergey,
AFAIK the way the __FILE__ macro is formatted depends on how you provide the source file names to the compiler, e.g:
file.c:
If you want both to be aligned there's a more general consideration:
MinGW uses POSIX paths (with slashes). I'm not aware that you can change VS to use POSIX instead. Maybe you can convince MinGW to use Windows paths (with backslashes). Unfortunately I've never tried that with MinGW.
Best regards,
Georg Zitzlsberger
AFAIK the way the __FILE__ macro is formatted depends on how you provide the source file names to the compiler, e.g:
file.c:
[cpp]#includeint main(int argc, char **argv) { printf("%sn", __FILE__); return 0; }[/cpp]
[bash]C:temp> icl file.c C:temp> file.exe file.c[/bash]or
[bash]C:temp> icl C:tempfile.c C:temp> file.exe C:tempfile.c[/bash]
If you want both to be aligned there's a more general consideration:
MinGW uses POSIX paths (with slashes). I'm not aware that you can change VS to use POSIX instead. Maybe you can convince MinGW to use Windows paths (with backslashes). Unfortunately I've never tried that with MinGW.
Best regards,
Georg Zitzlsberger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting Georg Zitzlsberger (Intel)
...Maybe you can convince MinGW to use Windows paths (with backslashes). Unfortunately I've never tried that with MinGW...
That would be nice. Thank you, Georg.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Georg,
I could replace all '\' with '/' in case ofVisual C++, but I can't reconstruct a full path in case of MinGW.
I could replace all '\' with '/' in case ofVisual C++, but I can't reconstruct a full path in case of MinGW.
MinGW: ../../folder3/test.cpp
Visual C++: c:/folder1/folder2/folder3/test.cpp
Anyway, I'll decide if it makes sence to spend time onthese updates.
Best regards,
Sergey
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page