On Mon, Sep 20, 2021 at 1:26 AM Pi Pony via cfe-users
<cfe-users@lists.llvm.org> wrote:
> ...
> It's so I can learn to use LLVM and Clang better and contribute to the 
> community, please pass the knowledge further.
>
> for ( struct { int i; char* ptr; } loopy = { 0, "LLVM" };
>
>       loopy.i < 10 && * loopy.ptr != 0;
>
>       ++ loopy.i, ++ loopy.ptr )
>
>     { ... }

This is probably better suited for Stack Overflow.

It looks like you're coming from some other language. Try this instead.

$ cat test.c
#include <stdlib.h>

struct loopy
{
  int i;
  char* ptr;
};

int main(int argc, char* argv[])
{
  struct loopy loops[] =
  {
     {0, "LLVM"},
     {0, NULL}
  };

  for (struct loopy* ptr = loops;
       ptr->i < 10 && ptr->ptr != NULL;
       ++ptr)
  {
      /* ... */
  }

  return 0;
}

$ clang test.c -o test.exe
$ ./test.exe
$

Jeff
_______________________________________________
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Reply via email to