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

Type aliases for arrays are not recognized #263

Open
matthew-limbinar opened this issue Sep 30, 2024 · 1 comment
Open

Type aliases for arrays are not recognized #263

matthew-limbinar opened this issue Sep 30, 2024 · 1 comment

Comments

@matthew-limbinar
Copy link

matthew-limbinar commented Sep 30, 2024

Brilliant piece of work here! It has impressed me many times already.

Here is one little snafu that I experienced with v3.1.2:

import cppyy
cppyy.cppdef("using IntArray = int[5];") # or "typedef int IntArray[5];"
X = cppyy.gbl.IntArray

which yields:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: <namespace cppyy.gbl at 0x2d8e890> has no attribute 'IntArray'. Full details:
  type object '' has no attribute 'IntArray'
  'IntArray' is not a known C++ class
  'IntArray' is not a known C++ template
  'IntArray' is not a known C++ enum

Similarly, I can do this:

cppyy.cppdef("""
  struct Holder { 
    using IntArray = int[7]; 
    IntArray a;
  };
""")

x = Holder() # Ok!
print(len(x.a)) # Prints "7"

y = Holder.IntArray() # ERROR! (as above)

Workaround: use std::array<int, 5> instead.

Thanks again for the quality project!

@wlav
Copy link
Owner

wlav commented Sep 30, 2024

Yes, Cling does not expose using in classes. It's on my wish list.

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

No branches or pull requests

2 participants