www.digitalmars.com         C & C++   DMDScript  

c++ - Namespace in header

reply "Charl Marais" <NO__SPAM_maraischarl hotmail.com> writes:
Hi all

I'm trying to compile a very simple program from an example out of a book.
Unfortunately, when I compile the header file, I get:

Error E2141 PromptModule.h 4: Declaration syntax error

with the code:

#ifndef PromptModuleH
#define PromptModuleH

namespace PromptModule        //where error occurs
{
    void PauseProgram();
}
#endif


If I take the namespace code out, it works fine. It also compiles the cpp
file with namespace code in. I'm using Borland 5.5 compiler on windows XP.

Any help will be appreciated

thanks

Charl Marais
May 05 2003
next sibling parent Jan Knepper <jan smartsoft.us> writes:
news://forums.inprise.com/borland.public.cppbuilder.commandlinetools

You should FORCE the compiler to process the HEADER file as C++ file with
dmc -c -cpp PromptModule.h

More normal is including the .h file into a .cpp file.

ManiaC++
Jan



Charl Marais wrote:

 Hi all

 I'm trying to compile a very simple program from an example out of a book.
 Unfortunately, when I compile the header file, I get:

 Error E2141 PromptModule.h 4: Declaration syntax error

 with the code:

 #ifndef PromptModuleH
 #define PromptModuleH

 namespace PromptModule        //where error occurs
 {
     void PauseProgram();
 }
 #endif

 If I take the namespace code out, it works fine. It also compiles the cpp
 file with namespace code in. I'm using Borland 5.5 compiler on windows XP.

 Any help will be appreciated

 thanks

 Charl Marais

May 05 2003
prev sibling next sibling parent "Charl Marais" <NO__SPAM_maraischarl hotmail.com> writes:
Thanks


"Charl Marais" <NO__SPAM_maraischarl hotmail.com> wrote in message
news:b976lb$1kha$1 digitaldaemon.com...
 Hi all

 I'm trying to compile a very simple program from an example out of a book.
 Unfortunately, when I compile the header file, I get:

 Error E2141 PromptModule.h 4: Declaration syntax error

 with the code:

 #ifndef PromptModuleH
 #define PromptModuleH

 namespace PromptModule        //where error occurs
 {
     void PauseProgram();
 }
 #endif


 If I take the namespace code out, it works fine. It also compiles the cpp
 file with namespace code in. I'm using Borland 5.5 compiler on windows XP.

 Any help will be appreciated

 thanks

 Charl Marais

May 05 2003
prev sibling parent "Walter" <walter digitalmars.com> writes:
"Charl Marais" <NO__SPAM_maraischarl hotmail.com> wrote in message
news:b976lb$1kha$1 digitaldaemon.com...
 Error E2141 PromptModule.h 4: Declaration syntax error

I'm afraid that's a borland compiler problem. The solution is to download the Digital Mars compiler from www.digitalmars.com/download/freecompiler.html
May 09 2003