Thread: Defining the correct location of a type declaration

  1. #1
    Registered User vinians's Avatar
    Join Date
    Mar 2015
    Posts
    5

    Defining the correct location of a type declaration

    Hello guys!
    I'm creating a C project where I have a list of files like:
    Script.c

    tokenizer.h
    tokenizer.c

    In tonkenizer.h I have all prototypes of funcions used in tokenizer.c and a TToken struct declaration.
    My problem is that I need to use TToken structure in Script.c and in tokenizer.c but if I include tokenizer.h in Script.c it will include all tokenizer.c prototype function too and I will get an error.
    What's the best and clean solution for this issue?

    Thanks in advance!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,901
    Perhaps you should post the actual error message.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User vinians's Avatar
    Join Date
    Mar 2015
    Posts
    5
    Quote Originally Posted by Salem View Post
    Perhaps you should post the actual error message.
    I solved the problem spliting function declaration from type declaration to a types.h.
    Thank you

  4. #4
    Registered Superuser nul's Avatar
    Join Date
    Nov 2014
    Location
    Earth
    Posts
    53
    Also take a look at inclusion guards.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 08-31-2009, 01:52 PM
  2. Forbids Declaration of '___' with no type
    By warfang in forum C++ Programming
    Replies: 6
    Last Post: 03-26-2007, 11:01 PM
  3. the correct syntax for ''char'' type
    By benasp in forum C Programming
    Replies: 1
    Last Post: 02-21-2005, 05:39 PM
  4. variable type declaration
    By threahdead in forum C Programming
    Replies: 4
    Last Post: 02-27-2003, 05:45 PM
  5. Forbids Declaration with No Type
    By ProgrammingDlux in forum C++ Programming
    Replies: 6
    Last Post: 03-24-2002, 07:39 PM

Tags for this Thread