Illegal reserved identifiers ( _ + capital letter) used in various classes

Issue #134 resolved
Chris Richardson created an issue

I am just trying to compile dolfin with a new compiler, and it is complaining about reserved identifiers.

It seems it is quite right...

http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier

There may be a workaround, but would it be possible to eliminate all identifiers that begin with underscore+capital letter combination?

Comments (18)

  1. Chris Richardson reporter

    What should the alternative be?

    _L  => L (may not always be possible, and may be confusing)
    _L  => _xL (ugly)
    _L  => m_L (advocated by some)
    _L  => L_
    
  2. Anders Logg (Chalmers)

    Is it just for L? I don't think we have that many variables beginning with a capital letter.

    In general, I think we should strive for names like form in place of a and matrix in place of A. That could take care of some of these issues (replace by _linear_form).

  3. Prof Garth Wells

    That's fine.

    I marked this as a target for release 1.4. I don't think it's worth worrying about much for the next release (1.3).

  4. Johannes Ring

    I am trying to build DOLFIN on Cygwin and ran into this issue. Could we fix this now?

    Here are some files affected by this:

    $ find dolfin/ -name "*.h" | xargs grep " _[A-Z];"
    dolfin/multistage/PointIntegralSolver.h:    std::vector<double> _F;
    dolfin/adaptivity/ErrorControl.h:    std::shared_ptr<const FunctionSpace> _E;
    dolfin/adaptivity/ErrorControl.h:    std::shared_ptr<const FunctionSpace> _B;
    dolfin/adaptivity/ErrorControl.h:    std::shared_ptr<const FunctionSpace> _C;
    dolfin/la/EpetraLUSolver.h:    std::shared_ptr<const EpetraMatrix> _A;
    dolfin/la/CholmodCholeskySolver.h:    std::shared_ptr<const GenericLinearOperator> _A;
    dolfin/la/EpetraMatrix.h:    std::shared_ptr<Epetra_FECrsMatrix> _A;
    dolfin/la/PETScKrylovSolver.h:    std::shared_ptr<const PETScBaseMatrix> _A;
    dolfin/la/PETScKrylovSolver.h:    std::shared_ptr<const PETScBaseMatrix> _P;
    dolfin/la/UmfpackLUSolver.h:    std::shared_ptr<const GenericLinearOperator> _A;
    dolfin/la/MUMPSLUSolver.h:    std::shared_ptr<const CoordinateMatrix> _A;
    dolfin/la/SLEPcEigenSolver.h:    std::shared_ptr<const PETScMatrix> _A;
    dolfin/la/SLEPcEigenSolver.h:    std::shared_ptr<const PETScMatrix> _B;
    dolfin/la/LinearAlgebraObject.h:      return _A;
    dolfin/la/EpetraKrylovSolver.h:    std::shared_ptr<const EpetraMatrix> _A;
    dolfin/la/EpetraKrylovSolver.h:    std::shared_ptr<const EpetraMatrix> _P;
    dolfin/la/PETScBaseMatrix.h:    { return _A; }
    dolfin/la/PETScBaseMatrix.h:    Mat _A;
    dolfin/la/PETScLUSolver.h:    std::shared_ptr<const PETScMatrix> _A;
    dolfin/la/uBLASMatrix.h:    { return _A; }
    dolfin/la/uBLASMatrix.h:    { return _A; }
    dolfin/la/uBLASMatrix.h:    Mat _A;
    dolfin/la/LinearOperator.h:    std::shared_ptr<GenericLinearOperator> _A;
    dolfin/la/uBLASKrylovSolver.h:    std::shared_ptr<const GenericLinearOperator> _A;
    dolfin/la/uBLASKrylovSolver.h:    std::shared_ptr<const GenericLinearOperator> _P;
    dolfin/nls/NewtonSolver.h:    std::shared_ptr<GenericMatrix> _A;
    dolfin/fem/LinearVariationalProblem.h:    std::shared_ptr<const Form> _L;
    dolfin/fem/LinearTimeDependentProblem.h:    std::shared_ptr<const TensorProductForm> _L;
    dolfin/fem/PointSource.h:    std::shared_ptr<const FunctionSpace> _V;
    dolfin/fem/SystemAssembler.h:    std::shared_ptr<const Form> _a, _L;
    dolfin/fem/NonlinearVariationalProblem.h:    std::shared_ptr<const Form> _F;
    dolfin/fem/NonlinearVariationalProblem.h:    std::shared_ptr<const Form> _J;
    
  5. Prof Garth Wells

    I'd suggest:

    _A -> _matA
    _P -> _matP
    _L -> _l
    _V -> _function_space
    _J -> _jacobian
    _F -> _residual
    
  6. Prof Garth Wells

    @logg A Krylov solver holds two matrices for real-world problems - the operator A and the preconditioner P. _matrix is not a suitable name.

  7. Anders Logg (Chalmers)

    @garth-wells As I wrote earlier, the suggestion is _matrix and _preconditioner, or _operator and _preconditioner.

  8. Prof Garth Wells

    @logg P is a matrix. _matrix and _preconditioner are not suitable because both are matrices/operators. A and P are commonly used notation, so it's reasonable that they appear in the names, as they do now.

  9. Log in to comment