Questions tagged [incomplete-type]

In the C and C++ languages, an incomplete type is "lacking sufficient information to determine the size of objects of that type." (Examples: variable-length arrays, forward declarations of `struct`s, and the `void` type.)

In the C and C++ programming language, an incomplete type is

"lacking sufficient information to determine the size of objects of that type."ISO C11 standard, section 6.2.5

Examples:

The standard mentions the following three instances of incomplete types:

  1. an array type of variable, or unknown size, such as char *argv[].
  2. a type that describes an object but lacks information to determine their sizes, such as struct foo_tag;
  3. the void type (which, unlike the other two, cannot be completed)

Resources:

310 questions
-1
votes
1 answer

C: Why do I get the compile error "dereferencing pointer to incomplete type ‘struct xy’"?

I have the problem described in the headline above. These are my files and their code: run.c: [...] // I think it's not relevant for the problem declarations.h: #ifndef DECLARATIONS_H #define DECLARATIONS_H #include #include…
a kind person
  • 249
  • 5
  • 13
-1
votes
1 answer

Error: return type 'class Polar' is incomplete, invalid use of type 'polar'

I wanted to use casting operator to cast the Rect class to Polar class, But i am getting error stating "incomplete type". I am not getting any error on using pointers instead of the object itself. But I can't return a pointer to object for the…
-1
votes
1 answer

How to make classes using each other

class A; class B; class A { public: A(B * b) : b(b) { b->foo(this); } private: B * b; }; class B { public: void foo(A *) {} }; Compiling this code gives me incomplete-type.hpp: In constructor…
-1
votes
2 answers

C++ incomplete type class

i made a class in c++ and it had a member of the same class and it gave a incomplete type class error. class A{ private: A member; }; i found these "Incomplete type" in class which has a member of the same type of the class…
Nikhil
  • 61
  • 7
-1
votes
1 answer

Error: Incomplete templated type

I am having an issue using an incomplete templated type. I have searched quite a while for a solution but every answer I have found has tended to be along the lines of "include the header," "forward declare," or "you can't do that with STL." I…
Derek
  • 1
-1
votes
1 answer

expected class-name before '{' token, class inheritance

I have a problem with a file of my project, i guess caused by some include issues. The code itself worked fine but since I changed some lines in some other files I get a 'expected class name before '{' token' error. I've already tried to use forward…
-1
votes
1 answer

Passing argument 1 of 'strcmp' from incompatible pointer type

I'm aware that these questions are asked all of the time, however in this scenario I'm not quite sure what the proper solution would be. The function is an edited function of do_new_mount in a fork of the 3.4.x linux kernel for context. The intended…
user2337438
  • 29
  • 1
  • 7
-1
votes
1 answer

invalid application of 'sizeof' to an incomplete type struct

this is a bit puzzling to me because it worked in the past. I have a vector3 struct and a matrix4 struct which are defined like this common_struct.h looks like this struct { float m[16]; } mat4_scalar; struct { float p[3]; }…
user1610950
  • 1,557
  • 4
  • 22
  • 43
-1
votes
1 answer

stat.h file access file descriptors open() Hacking The Art of Exploitation

I am working out of the 2nd edition of Jon Erickson's "Hacking: The Art of Exploitation" using a VM (virutalbox) to run the LiveCD it came with (Ubuntu 7.04). In section 0x281 "File Access", the author explains accessing files through file…
user1234
  • 11
  • 4
-1
votes
1 answer

error: incompatible types with 2D array and .split

Feel stupid asked like the exact same question yesterday but today with a different situations can do the same thing. single[z][i] = (board[i].split("?!^")); This line gives me an error: incompatible types required: String found: String[] 1…
JT attack
  • 77
  • 1
  • 1
  • 8
-1
votes
1 answer

template with forward class declaration

I have one library that declared a template function: template void Foo(blah...) { class Bar mybar; ... } class Bar is not defined in this library, but since it's just a template it should not be instantiated at this time; so by…
Shine
  • 1
  • 1
-1
votes
1 answer

Error finding a Class even when it's predefined

class Slice ; class Apple{ ... Slice x; }; class Slice{ ... }; Even though I defined that class Slice exists. When I call it in my class Apple to create a Slice object 'x', the compiler gives me an error:field x has an incomplete…
Wiking
  • 13
  • 1
-1
votes
1 answer

Why type struct BMPFILE_ is incomplete? in C

in bmpfile.h I define struct: struct BMP_FILE_ { BMPHEADER header; BITMAPINFOHEADER dib; unsigned char channels; rgb_px_t **pixels; rgb_px_t *pal; } BMPFILE_, *pBMPFILE; typedef struct BMPFILE_ BMPFILE; BMPFILE * bmp_create(uint32_t width,…
John Boe
  • 3,016
  • 10
  • 32
  • 56
-1
votes
1 answer

Why do templates allow for method types of unfinished classes?

Why do templates let you get around incomplete types? I was following an example in a textbook on Nodes, Linked lists and Iterators. I noticed he used a pointer to instances of Lists and Nodes in the Iterator class, but then he also created a…
Congomon
  • 13
  • 3
-1
votes
1 answer

Incomplete type not allowed

I am trying to create a queue by allocating memory to a pointer to a queue, yet I get this error when I write the name of the struct in the size slot. I really don't know how to explain this, so code: structs, defined in queue.c: struct queue { …
Sunspawn
  • 767
  • 1
  • 8
  • 26
1 2 3
20
21