-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Workaround clang4.0 <stdatomic.h> initialization #trivial #426
Conversation
@maicki looked at this with me and confirmed this should be okay |
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.
Looks good to me, but let's have @Adlai-Holler have another look over it.
@bkase We actually do need automatic storage duration on this variable =/. Since the current implementation of |
P.S. A more complete solution to this is to move the implementation of ASDispatchApply into a .m (or .c) file so that it's never compiled by a C++ compiler. In the header just surround the function declaration by |
3973c9e
to
ac6dd31
Compare
@Adlai-Holler yeah it's blocking the bazel build of master -- how's that comment? |
Texture fails to build with this error on clang 4.0: ``` external/Texture/pod_support/Headers/Public/AsyncDisplayKit/ASDispatch.h:32:35: error: illegal initializer type 'atomic_size_t' (aka '_Atomic(size_t)') __block atomic_size_t counter = ATOMIC_VAR_INIT(0); ^ In module 'std' imported from external/Texture/pod_support/Headers/Public/AsyncDisplayKit/ASStackUnpositionedLayout.h:18: /private/var/tmp/_bazel_bkase/a00d4cbe29902fb63d5778cc19944cd2/external/clang40/bin/../include/c++/v1/atomic:1839:30: note: expanded from macro 'ATOMIC_VAR_INIT' ^ 1 error generated. ``` See http://techqa.info/programming/question/38233019/Initializing-an--atomic-int--with-a-braced-constant--Is-this-valid-C-code--If-so-why-does-it-not-compile-in-clang- Replacing the intialization with just 0 (and not the macro fixes the error). For now this is safe because the macro just expands to the value.
ac6dd31
to
e985a57
Compare
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.
Down with it
Summary: This fixes the bazel build (now that we added Weaver) assuming the following PR gets merged and included in ASDK: TextureGroup/Texture#426
Texture fails to build with this error on clang 4.0: ``` external/Texture/pod_support/Headers/Public/AsyncDisplayKit/ASDispatch.h:32:35: error: illegal initializer type 'atomic_size_t' (aka '_Atomic(size_t)') __block atomic_size_t counter = ATOMIC_VAR_INIT(0); ^ In module 'std' imported from external/Texture/pod_support/Headers/Public/AsyncDisplayKit/ASStackUnpositionedLayout.h:18: /private/var/tmp/_bazel_bkase/a00d4cbe29902fb63d5778cc19944cd2/external/clang40/bin/../include/c++/v1/atomic:1839:30: note: expanded from macro 'ATOMIC_VAR_INIT' ^ 1 error generated. ``` See http://techqa.info/programming/question/38233019/Initializing-an--atomic-int--with-a-braced-constant--Is-this-valid-C-code--If-so-why-does-it-not-compile-in-clang- Replacing the intialization with just 0 (and not the macro fixes the error). For now this is safe because the macro just expands to the value.
Texture fails to build with this error on clang 4.0:
See
http://techqa.info/programming/question/38233019/Initializing-an--atomic-int--with-a-braced-constant--Is-this-valid-C-code--If-so-why-does-it-not-compile-in-clang-
Replacing the intialization with just 0 (and not the macro fixes the
error). The forum post notes:
Since we don't need the automatic storage duration either, this code
should still be correct.