-
Notifications
You must be signed in to change notification settings - Fork 177
Fixes to format preprocessing for Clang on Windows #886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Clang on Windows defines _MSC_VER, but it doesn't understand _Printf_format_string_
Do you know how we could add a Clang on windows CI target? |
I believe just copying the action that uses clang-cl and making it use clang instead should work? Not entirely sure, can test it out on my fork |
Please add it to this PR so we test it there too going forward. |
@@ -102,7 +102,8 @@ extern "C" { | |||
|
|||
/* Borrowed from Folly */ | |||
#ifndef JS_PRINTF_FORMAT | |||
#ifdef _MSC_VER | |||
/* Clang on Windows doesn't seem to support _Printf_format_string_ */ | |||
#if defined(_MSC_VER) && !defined(__clang__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this change also in quickjs.h, for consistency?
@@ -102,7 +102,8 @@ extern "C" { | |||
|
|||
/* Borrowed from Folly */ | |||
#ifndef JS_PRINTF_FORMAT | |||
#ifdef _MSC_VER | |||
/* Clang on Windows doesn't seem to support _Printf_format_string_ */ | |||
#if defined(_MSC_VER) && !defined(__clang__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this change also in quickjs.h, for consistency?
@@ -7048,7 +7048,7 @@ static int JS_PRINTF_FORMAT_ATTR(3, 4) JS_ThrowTypeErrorOrFalse(JSContext *ctx, | |||
} | |||
} | |||
|
|||
#ifdef __GNUC__ | |||
#if defined(__GNUC__) || defined(__clang__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought clang also defined GNUC, doesn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least locally that seems to not be the case when compiling on Windows, though not sure why
I keep running into quirks with weird things not being compatible with Clang (for example the |
Clang on Windows defines
_MSC_VER
, but it doesn't seem to understand_Printf_format_string_
, leading to errors code using format string parameters as it fails to understand that the parameters are format strings. However, the__attribute__((format))
syntax seems to work just fine, and so this PR enables that for Clang on Windows.For context, I am using clang (19.1.0) instead of clang-cl (because the latter doesn't work for some unknown reasons). I've checked that this still works on MSVC, though I don't know about the rest of the platforms because I didn't realize GitHub wouldn't run CI when I made the commit. Oh well, I'll see when CI runs for the PR, and push new commits to fix it if something goes wrong.