ive got code the will compile in windows but not linux and i really don't know what is going on here my error shows:
DynCharStack.h:5: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âDynCharStackâ
DynCharStack is a class.
// Specification file for the DynIntStack class
#ifndef DYNCHARSTACK_H
#define DYNCHARSTACK_H
class DynCharStack
{
private:
// Structure for stack nodes
struct StackNode
{
char item; // Value in the node
StackNode *next; // Pointer to the next node
};
StackNode *top; // Pointer to the stack top
public:
// Constructor
DynCharStack()
{ top = NULL; }
// Destructor
~DynCharStack();
// Stack operations
void push(char);
void pop();
bool isEmpty();
};
#endif
any ideas?
let me know if ya'll need more of my code like what calls to it. and this is for a final due tomorrow so any help would be GREATLY appreciated. thanks guys
Hmmm... this often happens when you include a header file and forgot to put a semi-colon at the end of something like a function declaration, like this:
stupid_header.h
1 2 3 4
#ifndef _STUPID_HEADER_H_
#define _STUPID_HEADER_H_
int add(int a, int b)
#endif
main.cpp
1 2 3 4 5 6
#include <iostream>
#include "stupid_header.h"
int main(void) {
std::cout << "Curses, I forgot the semicolon!\n";
}
ok...i looked all through my header and the only thing its declaring is the class DynCharStack, which doesn't really have any code before it except the
1 2
#ifndef DYNCHARSTACK_H
#define DYNCHARSTACK_H
you know of any other possible issues that could cause this?
it will compile just fine in windows, so i figure its a linux or compiler thing?
using gcc
Well I've never had that problem with gcc or Linux. It wouldn't make sense for it to be a bug in either...
Are those special characters (â=â, â,â, â;â, âasmâ or â__attribute__â) really occuring? If so, that might mean you're saving the file with some weird encoding. Make sure the file is in ANSI.