Build error with struct

Asked

Viewed 184 times

1

While trying to compile I am facing the following error:

..: error: storage size of 'PPFila' isn't known
..: error: storage size of 'AUTFila' isn't known

On this code line

struct  Fila PPFila, AUTFila;

To struct Queue this being in another file queue.c and I’m accessing using #include "Queue.h"

1 answer

2


Declare the struct Fila in the archive Queue.h and not in the queue.c. And obviously include the file Queue.h where you want it to be used

  • Exactly, I must create the strucs and method statements in . h leaving only the implementations in . c, had not noticed this, thank you

  • @Lucasfernandes: That’s not true! The definition (implementation) of structs in the .h makes its members accessible by the interface clients (public members), definitions made in the .c (separate from the declaration) make the members of its struct are inaccessible by the interface clients (private members). The second type is called "Opaque Structure".

  • @Lucasfernandes: https://en.wikipedia.org/wiki/Opaque_data_type

  • @Lacobus does not confuse definition (implementation) with statement. What you said is not correct. Definition goes in . c and statement no . h A statement is when you present the name to the program and the definition is when you instantiate. When doing struct File PPFila; is a definition and usually goes in a . c

  • @Amadeus: I think you need to revise your concepts: http://stackoverflow.com/questions/1410563/what-is-the-difference-between-a-definition-and-a-declaration

  • @Lacobus I don’t understand what you mean by your last comment. What’s on the link you provided is exactly what I commented on earlier. So, what concept should I review?

  • @Amadeus: This is a statement: struct foobar; and that’s a definition: struct foobar { int x; };. There are no rules saying in which files the definitions and statements should be made. The point here is that DEPENDING on the way the struct has been defined and declared the effect may vary, changing the visibility of the struct and/or its members to the interface client. The example you pointed out is an "opaque structure" that has its statement in the .h and its definition in .c, however, this is not a rule.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.