gamer-project / gamer

Main GAMER repository
Other
77 stars 59 forks source link

FORMAT_REAL and FORMAT_LONG definition errors #274

Closed milchada closed 9 months ago

milchada commented 9 months ago

I get the following error when trying to compile GAMER recently (this did not occur a few months ago):

TestProblem/Hydro/ClusterMerger/Init_TestProb_ClusterMerger.cpp: In function 'void SetParameter()':
../include/Macro.h:1006:28: error: expected primary-expression before '%' token
 1006 | #  define FORMAT_LONG      %- 21ld
      |                            ^
TestProblem/Hydro/ClusterMerger/Init_TestProb_ClusterMerger.cpp:496:44: note: in expansion of macro 'FORMAT_LONG'
  496 |       PRINT_WARNING( "END_STEP", END_STEP, FORMAT_LONG );
      |                                            ^~~~~~~~~~
../include/Macro.h:1006:31: error: unable to find numeric literal operator 'operator""ld'

My compiler settings are:

# gnu
# -------------------------------------------------------------------------------
# CXX         = g++                                       # serial compiler
CXX         = $(MPI_PATH)/bin/mpicxx                    # MPI compiler
#CXX         = CC                                        # cray wrapper script
 CXXFLAG     = -g -O3                                    # general flags
#CXXFLAG     = -g -O3 -std=c++11
#CXXFLAG     = -g -Ofast
 CXXFLAG    += -Wall -Wextra                             # warning flags
 CXXFLAG    += -Wno-unused-variable -Wno-unused-parameter \
               -Wno-maybe-uninitialized -Wno-unused-but-set-variable \
               -Wno-unused-result -Wno-unused-function \
               -Wno-implicit-fallthrough -Wno-parentheses
 OPENMPFLAG  = -fopenmp                                  # openmp flag
 LIB         =                                           # libraries and linker flags

The issue persists whether I use gcc-10, gcc-11 or gcc-12 (& of course update all the other dependencies accordingly). How to fix the issue in defining FORMAT_LONG (and FORMAT_REAL)?

hyschive commented 9 months ago

@milchada Thanks for reaching out. It appears that you are not using the latest main branch, where PRINT_WARNING() has been replaced with PRINT_RESET_PARA (see this example in the ClusterMerger test). So please try merging the latest main branch and let me know whether that solves the problem.

milchada commented 9 months ago

@hyschive i checked that i'm on the main branch and did a pull, it tells me I am at the latest branch; git log yields:

commit 01b060a112b522f1407f62d897a1715b157ae580 (HEAD -> main, origin/main, origin/HEAD)
Author: Hsi-Yu Schive <hyschive@gmail.com>
Date:   Fri Dec 15 22:24:39 2023 +0800

    Minor

but the error persists, even after a make clean.

hyschive commented 9 months ago

@milchada Have you modified TestProblem/Hydro/ClusterMerger/Init_TestProb_ClusterMerger.cpp? The error message you got, 496 | PRINT_WARNING( "END_STEP", END_STEP, FORMAT_LONG );, is inconsistent with the main branch (see here).

milchada commented 9 months ago

@hyschive ah that was it! I edited these starting from a previous version. thank you!