[cfe-users] need help with clang

2021-09-19 Thread Pi Pony via cfe-users
Hello to all,

WARNING: IF YOU ARE PROFESSIONAL PROGRAMMER PLEASE DONT READ THIS IT MAY
BURN YOUR EYES

i tried to compile a code that isn't compatible with clang, I want to know
how to make it work and if not how to add a feature so that it will work?

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 )

{ ... }



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


Re: [cfe-users] need help with clang

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

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