www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Namespace in header

↑ ↓ ← "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
→ 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
→ "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
→ "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