Skip to content
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

cc.has_header_symbol() does not work for struct definitions #1975

Closed
nirbheek opened this issue Jun 21, 2017 · 6 comments
Closed

cc.has_header_symbol() does not work for struct definitions #1975

nirbheek opened this issue Jun 21, 2017 · 6 comments

Comments

@nirbheek
Copy link
Member

# Always succeeds
cc.has_header_symbol('linux/fs.h', 'struct file_clone_range')

# Always fails
cc.has_header_symbol('linux/fs.h', 'file_clone_range')

This is because our check evaluates to:

struct file_clone_range;

Which is just a prototype definition.

@Salamandar
Copy link
Contributor

Salamandar commented Jan 28, 2020

No fix yet ? I've been using it for ages without knowing it was broken.
I'm guessing the check logic itself is broken.

@Salamandar
Copy link
Contributor

https://cmake.org/cmake/help/v3.0/module/CheckSymbolExists.html

If the symbol is a type or enum value it will not be recognized

CMake checks symbols ( = function, macro, variable) apart from types. Maybe Meson should do the same as it seems buggy to merge the two.

@pm215
Copy link

pm215 commented Nov 16, 2021

If I understand correctly, you can use cc.has_type() to test for the presence of "struct foo", eg

cc.has_type('struct iovec', prefix: '#include <sys/uio.h>')

Question: is there any valid use for passing a string with spaces in it to cc.has_header_symbol()? If not, would it be worth making that a syntax error or at least a warning, to catch accidental attempts to use it on "struct something" ? (The generated code for has_header_symbol() clearly doesn't envisage being passed multiple words, because it will generate "#ifndef struct foo", which is bogus syntax and provokes compiler warnings during compilation of the test case.)

(Commenting because we just fell over this with QEMU's meson.build.)

@nirbheek
Copy link
Member Author

If I understand correctly, you can use cc.has_type() to test for the presence of "struct foo", eg

Yes, this issue is obsolete now. I'll close it.

If not, would it be worth making that a syntax error or at least a warning, to catch accidental attempts to use it on "struct something" ?

Absolutely, yes. Could you open a PR that does that and CC me on it?

@pm215
Copy link

pm215 commented Nov 16, 2021

I'm not sufficiently familiar with meson's internals to submit a pullreq, I'm afraid.

@eli-schwartz
Copy link
Member

eli-schwartz commented Nov 16, 2021

That's okay, we can offer advice. :)

You can find the compiler implementations in mesonbuild/compilers/, the base (stub) implementation which raises NotImplementedError is in compilers.py and overridden implementations for each language include for this function, c.py and cpp.py and cuda.py

Check for def has_header_symbol :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants