Thread: Error: Incomplete type is not allowed?

  1. #1
    Registered User
    Join Date
    Apr 2012

    Wink Error: Incomplete type is not allowed?

    #pragma once
    #include "product.h"
    class DataStore
        unsigned int findPrice(int id, Product dataStore[], int size);
        void sortProductIDs(Product dataStore[], int size);
        void delete_id(Product dataStore[], int id, int size);
        void l_find_id_price(Product dataStore[], int * id, unsigned int * price, int size);
        static int const MAX = 5;
        DataStore theDataStore[MAX];

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Did you mean to make theDataStore static? Because otherwise, every instance of DataStore wants to contain 5 more instances of DataStore, which isn't possible.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    May 2011
    Around 8.3 light-minutes from the Sun
    I love to see C code with classes......wait a second, are you an apple programmer?
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  4. #4
    Join Date
    Oct 2007
    Inside my computer
    There was once an apple, which contained 5 other apples.
    Those other 5 apples, in turn, contained 5 more apples.
    Now, those 25 apples all contained another 5 apples each.
    And so on... yeah...

    Now, substitute "Apple" for "DataStore" and you've found your problem.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Jun 2005
    Unrelated to the original problem, but avoid using #pragma once. Better to use include guards in header files (same net effect, not compiler specific).
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-23-2011, 02:04 PM
  2. error: array type has incomplete element type
    By gerger in forum C Programming
    Replies: 8
    Last Post: 10-05-2010, 07:40 AM
  3. Compile Error: Incomplete Type
    By estebbins in forum C Programming
    Replies: 2
    Last Post: 07-07-2008, 10:00 PM
  4. error: field has incomplete type
    By kris.c in forum C Programming
    Replies: 11
    Last Post: 06-12-2007, 03:53 PM
  5. "error: incomplete type is not allowed"
    By Fahrenheit in forum C++ Programming
    Replies: 9
    Last Post: 05-10-2005, 09:52 PM