0

I'm writing a C program. Ones of its headers declares a structure like this:

struct s_emulator;

Then I define it in a source file:

struct s_emulator
{
    struct s_cpu cpu;
    struct s_screen screen;
    struct s_input in;
};

To finally use it in my main.c file:

struct s_emulator emulator;

Everything seems okay, but I get the following error messages:

src/main.c:7:23: error: storage size of ‘emulator’ isn’t known
    7 |     struct s_emulator emulator;
      |                       ^~~~~~~~
Umiko
  • 1
  • put the **definition** of s_emulator **before** your usage - only putting **declaration** before usage is not enough. – ch271828n Apr 15 '21 at 11:44
  • 3
    You define it in a different source file. That means the size of it is unknown in the context of main.c. You should just put the definition in the header. – Emanuel P Apr 15 '21 at 11:45

0 Answers0