|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#4
|
||||
|
||||
|
Re: The silly syntax errors that won't go away!
Quote:
In the file that needs to own them, in this case deck.c, flank the include statement with #define VAR_DECLARE the include #undef VAR_DECLARE Then in your header file, wrap all the code declaring the variables in #ifdef VAR_DECLARE code goes here #else extern code goes here #endif After the else copy your code defining the variables, but put extern in front of each, that means to the compiler "This is already declared elsewhere, use that version." Example: C file that owns header: Code:
#define VAR_DECLARE #include "header.h" #undef VAR_DECLARE Code:
#include "header.h" Code:
#ifdef VAR_DECLARE char myChar1; int myInt1; #else extern char myChar1; extern int myInt1; #endif |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C18 v2.4 -- Syntax error where there is no syntax error | Joel J | Programming | 7 | 12-01-2007 17:27 |
| Union Errors in AutoCAD | indieFan | Inventor | 4 | 16-07-2004 12:54 |
| PBASIC language syntax | WizardOfAz | Programming | 14 | 30-04-2003 10:23 |
| Digital inputs, bandwith, errors? | Micah Brodsky | Programming | 7 | 20-01-2003 16:08 |
| Specs full of errors??? | Simon G | Motors | 1 | 20-01-2003 12:53 |