CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

expected primary-expression before .....

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By floquation

Reply
 
LinkBack Thread Tools Display Modes
Old   November 3, 2014, 11:37
Default expected primary-expression before .....
  #1
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 675
Rep Power: 8
sharonyue is on a distinguished road
Hi guys,

I added this piece of code into the original one:
Code:
Foam::tmp<Foam::volScalarField> Foam::twoPhaseSystem::dragCoeff() const
{
    return drag_->K();
}

Foam::tmp<Foam::volScalarField> Foam::twoPhaseSystem::dragCoeff(const volScalarField& M30, const volScalarField& M20) const
{
    return drag_->K(const volScalarField& M30, const volScalarField& M20);
}
the compiler said:
Code:
twoPhaseSystem.C: In member function ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::twoPhaseSystem::dragCoeff(const volScalarField&, const volScalarField&) const’:
twoPhaseSystem.C:291:21: error: expected primary-expression before ‘const’
     return drag_->K(const volScalarField& M30, const volScalarField& M20);
                     ^
twoPhaseSystem.C:291:48: error: expected primary-expression before ‘const’
     return drag_->K(const volScalarField& M30, const volScalarField& M20);
                                                ^
twoPhaseSystem.C:292:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
make: *** [Make/linux64GccDPOpt/twoPhaseSystem.o] Error 1
Even I change it into:
Code:
Foam::tmp<Foam::volScalarField> Foam::twoPhaseSystem::dragCoeff() const
{
    return drag_->K();
}

Foam::tmp<Foam::volScalarField> Foam::twoPhaseSystem::dragCoeff(const volScalarField& M30, const volScalarField& M20) const
{
    return drag_->K(int A);
}
It crushed!!

But this is totally fine:
Code:
Foam::tmp<Foam::volScalarField> Foam::twoPhaseSystem::dragCoeff() const
{
    return drag_->K();
}

Foam::tmp<Foam::volScalarField> Foam::twoPhaseSystem::dragCoeff(const volScalarField& M30, const volScalarField& M20) const
{
    return drag_->K();
}
So it must be something wrong with this:
Code:
return drag_->K(const volScalarField& M30, const volScalarField& M20);

or

return drag_->K(int A);
But I dont know where its wrong. Any comments is appreciated!
Thanks
sharonyue is offline   Reply With Quote

Old   November 4, 2014, 04:11
Default
  #2
Member
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 30
Rep Power: 3
floquation is on a distinguished road
Quote:
Originally Posted by sharonyue View Post
So it must be something wrong with this:
Code:
return drag_->K(const volScalarField& M30, const volScalarField& M20);

or

return drag_->K(int A);
Indeed.
You need to distinguish parameter passing and receiving.

When you receive a parameter in a function (blue, below), you must specify its type. You are already doing this.
When you pass a variable to another function (purple, below), you must solely pass the variable, without including its type in front: the compiler already knows its type. If you do put its type in front, you are declaring a new variable, which you do not initialize. That will result in a compilation error.

Quote:
Originally Posted by sharonyue View Post
Code:
Foam::tmp<Foam::volScalarField>  Foam::twoPhaseSystem::dragCoeff(const volScalarField& M30, const  volScalarField& M20) const
{
    return drag_->K(const volScalarField& M30, const volScalarField& M20);
}
So, you should do:

Code:
Foam::tmp<Foam::volScalarField>  Foam::twoPhaseSystem::dragCoeff(const volScalarField& M30, const  volScalarField& M20) const
{
    return drag_->K(M30, M20);
}
sharonyue likes this.
floquation is offline   Reply With Quote

Old   November 4, 2014, 04:23
Default
  #3
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 675
Rep Power: 8
sharonyue is on a distinguished road
Exactly! Thank you very much!!!!!!!!!
bro!!
sharonyue is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to install CGNS under windows xp? lzgwhy Main CFD Forum 1 January 11, 2011 19:44
CGNS lib and Fortran compiler manaliac Main CFD Forum 2 November 29, 2010 07:25
POSDAT problem piotka STAR-CD 4 June 12, 2009 08:43
wmake compiling Problem with OF1.5 openTom OpenFOAM Installation 4 May 3, 2009 14:44
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51


All times are GMT -4. The time now is 14:15.