namespace error

This is a discussion on namespace error within the C++ Programming forums, part of the General Programming Boards category; Hi to all I am trying to execute c++ code which is used in OpenFoam software. Wheni execute it i ...

  1. #1
    Registered User
    Join Date
    Nov 2010

    Unhappy namespace error

    Hi to all

    I am trying to execute c++ code which is used in OpenFoam software. Wheni execute it i am getting error:'namespace definition is not allowed here in .C as well as in .H file.Could any one help me in this regard.

    Thanks in advance

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    What is the C++ compiler that you are using? Post the smallest and simplest program that demonstrates the error.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2010



    I am using Linux os with GNU compiler. I am trying to solve injector problem using OpenFoam software. In that i have to add boundary condition for that i have some .C and .H files Here are the files available in this link: Repository - [openfoam-extend] Index of /trunk/Core/OpenFOAM-1.4.1-dev/src/finiteVolume/fields/fvPatchFields/derived/fixedMeanValue

    when i included these files to the standard .C and .H which are available in my computer(standered .C and .H files) and tried to execute it it is showing the following error:

    Making dependency list for source file cavitatingFoam.C
    SOURCE=cavitatingFoam.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/appl/OpenFOAM/OpenFOAM-1.6.x/src/finiteVolume/lnInclude -I/appl/OpenFOAM/OpenFOAM-1.6.x/src/transportModels -I/appl/OpenFOAM/OpenFOAM-1.6.x/src/transportModels/incompressible/lnInclude -I/appl/OpenFOAM/OpenFOAM-1.6.x/src/transportModels/interfaceProperties/lnInclude -I/appl/OpenFOAM/OpenFOAM-1.6.x/src/turbulenceModels/incompressible/turbulenceModel -I/appl/OpenFOAM/OpenFOAM-1.6.x/src/thermophysicalModels/barotropicCompressibilityModel/lnInclude -IlnInclude -I. -I/appl/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude -I/appl/OpenFOAM/OpenFOAM-1.6.x/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64Gcc43DPOpt/cavitatingFoam.o
    In file included from cavitatingFoam.C:46:
    fixedMeanValueFvPatchField.H: In function ‘int main(int, char**)’:
    fixedMeanValueFvPatchField.H:42: error: ‘namespace’ definition is not allowed here
    In file included from fixedMeanValueFvPatchField.H:176,
    from cavitatingFoam.C:46:
    fixedMeanValueFvPatchField.C:32: error: ‘namespace’ definition is not allowed here
    /appl/OpenFOAM/OpenFOAM-1.6.x/src/finiteVolume/lnInclude/readPISOControls.H:11: warning: unused variable ‘transonic’
    /appl/OpenFOAM/OpenFOAM-1.6.x/src/finiteVolume/lnInclude/readPISOControls.H:3: warning: unused variable ‘nCorr’

    So could you please help me in this regard

    i would be greatful to you

    Thanks in advance


  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Find the nearest forum / newsgroup to the source.

    Maybe here

    Several things to bear in mind
    1. They've probably seen it already
    2. They probably know how to fix it in the best way (if they haven't done so already)
    3. They have the most motivation to get it fixed quickly

    Here, you're just taking a blind shot in the dark that someone might just know something.

    How To Ask Questions The Smart Way
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    May 2009
    Post the code for cavitatingFoam.C; if it is like the code here
    OpenFOAM programmer's C++ documentation

    Then I say the cavitatingFoam.C code is VERY poorly written.
    They are using #include from inside the main function; this is really really bad stuff.

    Tim S.
    Last edited by stahta01; 11-12-2010 at 06:12 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what am I missing? (Program won't compile)
    By steals10304 in forum C Programming
    Replies: 3
    Last Post: 08-25-2009, 04:01 PM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 02:01 AM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21