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

Can't compile reflection/one.cxx #190

Open
felixf4xu opened this issue Oct 9, 2023 · 1 comment
Open

Can't compile reflection/one.cxx #190

felixf4xu opened this issue Oct 9, 2023 · 1 comment

Comments

@felixf4xu
Copy link

Hi,

I downloaded build 200 and tried to compile https://github.com/seanbaxter/circle/blob/master/reflection/one.cxx but I got this error:

code:

#include <cstdio>
#include <string>

struct record_t {
  std::string first;
  std::string last;
  char32_t middle_initial;
  int year_of_birth;  
};

template<typename type_t>
void print_members() {
  printf("%s:\n", @type_string(type_t));
  @meta for(int i = 0; i < @member_count(type_t); ++i) {
    printf("%d: %s - %s\n", i, @member_type_string(type_t, i), 
      @member_name(type_t, i));
  }
}

int main() {
  print_members<record_t>();
}

output:

ODR used by: int main()
one.cxx:21:26
  print_members<record_t>(); 
                         ^

  error: command line macros:2:1
  object has invalid storage duration
  
  ^

I played it a little more by deleting random code and found that if I delete @meta then the following code can compile:

  for(int i = 0; i < @member_count(type_t); ++i) {
    printf("%d: %s - %s\n", i, @member_type_string(type_t, i),
      @member_name(type_t, i));
  }

but the output is incorrect:

record_t:
0: std::string - first
1: std::string - first
2: std::string - first
3: std::string - first
@felixf4xu
Copy link
Author

I'm not sure if it's related circle classic and new circle as mentioned at https://github.com/seanbaxter/circle/blob/master/new-circle/README.md#meta

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

1 participant