[cfe-users] need help with clang

Jeffrey Walton via cfe-users cfe-users at lists.llvm.org
Sun Sep 19 23:29:46 PDT 2021


On Mon, Sep 20, 2021 at 1:26 AM Pi Pony via cfe-users
<cfe-users at 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


More information about the cfe-users mailing list