1
votes

I've been stumped over this one:

SpanLogger_c.h

#ifndef SPANLOGGERCH
#define SPANLOGGERCH

struct CSpan
{
    int64_t trace_id;
};

#endif

main.c

#include "SpanLogger_c.h"

int main(int argc, char * const argv[]) {
  struct CSpan span;
}

compilation command:

g++ -g -I. main.c 

I get this error

main.c: In function ‘int main(int, char* const*)’:
main.c:7: error: aggregate ‘CSpan span’ has incomplete type and cannot be defined

Anybody help?

1
How can the error message be for line 7 when main.c only has 5 lines? Is that actually what main.c looks like? Also, why are you compiling a .c file with a C++ compiler?jwodder
There a couple of blank lines at the top. I'm trying to debug a larger project. I just tried gcc, and it works fine. Does'nt work with g++Arun
g++ is for C++ programs; gcc is for C programs.M.M

1 Answers

2
votes

In SpanLogger_c.h:

#include <stdint.h> 

If you're intending to write C++ use:

#include <cstdint>