Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22024

Designated Initializer Array in C

$
0
0

I'm trying to initialize an struct array using designated initializer:

A[size].from = {[0 ... size - 1] = 0};A[size].to = {[0 ... size - 1] = 0};

List.h:

typedef struct Buffer{    int from;    int to;}buffer_t;typedef struct shared_memory{buffer_t A;int size;} share_t

Main.c

#include <stdio.h>    #include "list.h"buffer_t A[];int size;void main(int argc, char *argv[]){    share->share_t *share = (share_t *)malloc(sizeof(share_t));    long arg = strtol(argv[1], NULL, 10);    size = arg;    share->A[size] = {[0 ... size-1] = 0};}

However this is the following error I'm receiving:

enter image description here

I'm using MinGW gcc and command prompt to compile this code and I'm writing this code in Visual studio.


Viewing all articles
Browse latest Browse all 22024

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>