Thread: Multiple definition errors for seemingly no reason at all

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    4

    Multiple definition errors for seemingly no reason at all

    I don't know what to think, here. Basically, what I have are three constants stored in a header file, that my compiler (Dev C ver. 4.9.9.2) is telling me have multiple definitions. I have done everything that I know to do (such as using ifndef/endif) to try and get these errors to go away, but it doesn't work.

    Here is some of the relevant code:
    Code:
    #ifndef _CONSTANTS_H
    #define _CONSTANTS_H
    
    const int MAX_ID_SIZE = 16;
    const int FILE_BUFFER_SIZE = 80;
    const int SYMBOL_TABLE_SIZE = 32;
    
    #endif
    Code:
    #ifndef _INITIALIZATION_H
    #define _INITIALIZATION_H
    #include "ScannerParams.h"
    #include "Constants.h"
    
    void InitializeSymbolTable(symbol * symbolTable);
    
    #endif
    Code:
    //Initialization.c
    #include "Initialization.h"
    
    void InitializeSymbolTable(symbol * symbolTable){
       int x;
       for(x = 0; x < SYMBOL_TABLE_SIZE; x++){
          symbolTable[x].info = NULL;
          symbolTable[x].token_Code = -1;      
       }
    }
    Code:
    //main.c
    #include "Initialization.h"
    
    int HashKey(char * key){
       int keyIndex = 0;
       int x;
       for(x = 0; x < MAX_ID_SIZE; x++){
    ....
    ^This code in main.c is the only place where MAX_ID_SIZE is currently being used right now; for whatever reason, C has decided that by using this constant, I am therefore "redefining" it. I don't know how or why.

    Do you guys have any ideas on what I'm doing wrong?
    Last edited by jmc4518; 03-16-2013 at 08:44 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multiple definition error, one definition
    By frog in forum C++ Programming
    Replies: 9
    Last Post: 10-21-2010, 03:15 AM
  2. multiple definition??
    By coni in forum C Programming
    Replies: 4
    Last Post: 09-11-2009, 07:55 PM
  3. Multiple Definition Problem
    By EASports in forum Linux Programming
    Replies: 2
    Last Post: 07-14-2009, 11:42 AM
  4. Multiple Definition
    By Finfarfin in forum C++ Programming
    Replies: 1
    Last Post: 12-06-2006, 04:18 PM
  5. Seemingly correct printf statements bringing up errors
    By hpteenagewizkid in forum C Programming
    Replies: 9
    Last Post: 11-08-2006, 12:13 PM