Hi,
Despite triple checking my code for duplication and checking that the headers include #ifndef I still can't trace what is causing this error message:
drawscr.o(.bss+0x0):drawscr.cpp: multiple definition of `massage'
main.o(.bss+0x0):main.cpp: first defined here
Ideally I'd create the pointer at struct definition time via a declarator.
// drawscr.cpp
#include <iostream>
#include <string>
#include "drawscr.h"
using namespace std;
void initMsg() {
/* initMsg(void)
return void;
Generate the stock strings for the fancy formatting
*/
message->top[0] = '\xC9';
for (int i=1;i<SCRNSIZE-2;i++) message->top[i] = '\xCD';
message->top[SCRNSIZE] = '\xBB';
message->blank[0] = '\xBA';
for (int i=1;i<SCRNSIZE-2;i++) message->blank[i] = '\f';
message->blank[SCRNSIZE] = '\xBA';
}
// drawscr.h
#ifndef _DRWSCREEN_H
#define _DRWSCREEN_H
using namespace std;
using std::string;
#define SCREEN Screen
#define CLS 0
#define SCRNSIZE 80
struct Screen {
int w;
int h;
int curX;
int curY;
};
struct MsgStock {
char top[SCRNSIZE];
char blank[SCRNSIZE];
} *message;
// prototypes
void initMsg();
void writeMsg(string);
#endif /* _DRWSCREEN_H */
// main.cpp
#include <iostream>
#include <string>
#include "drawscr.h"
using namespace std;
using std::string;
int main() {
initMsg();
cout << message->top;
return 0;
}