macro "min" error when Enzo includes a new header file

15 views
Skip to first unread message

Yusuke Fujimoto

unread,
Oct 18, 2016, 6:35:53 PM10/18/16
to enzo-dev
Hi Enzo developers,

This is the same topic I posted to "enzo-user" mailing list 3 days ago.

I am trying to do an isolated galactic disk simulation with star formation and feedback with a stellar population synthesis code, SLUG, which tells us yields of isotopes ejected from star particles.

For that, I call a new object, slug_cluster, in Grid_StarParticleHandler.C for each star particle and try to attach the slug_cluster objects to star particles when they form, just like their creation time, dynamical time, mass, position, and velocity.

In Grid.h, I include a header file, slug.H,

#ifndef GRID_DEFINED__

#define GRID_DEFINED__

#include "slug.H"

#include "ProtoSubgrid.h"

#include "ListOfParticles.h"

#include "region.h"


And add a new particle attribute, like this,

  FLOAT *ParticlePosition[MAX_DIMENSION];  // pointers to position arrays

  float *ParticleVelocity[MAX_DIMENSION];  // pointers to velocity arrays

  float *ParticleAcceleration[MAX_DIMENSION+1];  // 

  float *ParticleMass;                     // pointer to mass array

  PINT  *ParticleNumber;                   // unique identifier

  int   *ParticleType;                     // type of particle

  float *ParticleAttribute[MAX_NUMBER_OF_PARTICLE_ATTRIBUTES];

  slug_cluster *ParticleSlugObject;


Unfortunately, compiling fails. The error messages are,


Compiling enzo.C


CC -c -o enzo.o -DLINUX -DH5_USE_16_API   -D__max_subgrids=100000 -D__max_baryons=30 -D__max_cpu_per_node=8 -D__memory_pool_size=100000 -DINITS64 -DLARGE_INTS -DCONFIG_PINT_8 -DIO_32    -DUSE_MPI   -DCONFIG_PFLOAT_8 -DCONFIG_BFLOAT_8  -DUSE_HDF5_GROUPS   -DTRANSFER   -DNEW_GRID_IO -DFAST_SIB      -DENZO_PERFORMANCE   -DUSE_SLUG  -DSAB -std=c++11 -g -I/opt/cray/hdf5/1.8.14/gnu/5.1//include -I../src/enzo  -I.       -I/work/fujimtys/slug2_orig/src -I/home/fujimtys/boost/include -I/home/fujimtys/gsl/include    -I. enzo.C


In file included from /home/fujimtys/boost/include/boost/limits.hpp:19:0,

                 from /home/fujimtys/boost/include/boost/integer_fwd.hpp:16,

                 from /home/fujimtys/boost/include/boost/integer/integer_mask.hpp:13,

                 from /home/fujimtys/boost/include/boost/random/mersenne_twister.hpp:26,

                 from /work/fujimtys/slug2_orig/src/slug.H:26,

                 from Grid.h:15,

                 from enzo.C:43:

/opt/gcc/6.1.0/snos/include/g++/limits:320:11: error: macro "min" requires 2 arguments, but only 1 given

       min() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }

I guess slug.H and the macros defined in macros_and_parameters.h and EnzoTiming.h conflict with each other and the order of the header files might be important.
But, in enzo.C, Grid.h is included after macros_and_parameters.h and EnzoTiming.h, so I cannot avoid the error.

Am I implementing it wrong, or missing something more fundamental?
Does anyone have a good idea?
I am sorry for duplicate posts. I have been stuck in this problem for a few weeks. I need your help.


Thank you,
Yusuke Fujimoto

Nathan Goldbaum

unread,
Oct 18, 2016, 6:57:38 PM10/18/16
to enzo...@googlegroups.com
You have two headers with conflicting symbols that you are including. The fix is to remove the conflicting symbols from one of the headers. Enzo was not written in such a way that including an arbitrary header will work out of the box no matter what.

You could modify slug.H so it does not include any symbols that cause conflicts. One way people do this commonly is to prefix symbols with a name that is unlikely to be used by other libraries, so replace min with SLUG_min. Enzo could also do the same thing to ease integration with outside code, but you likely have more control over modifying slug than Enzo.

Another strategy would be to create a "wrapper" header around slug.H that does the aliasing for you, as in this StackOverflow example:

--
You received this message because you are subscribed to the Google Groups "enzo-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to enzo-dev+unsubscribe@googlegroups.com.
To post to this group, send email to enzo...@googlegroups.com.
Visit this group at https://groups.google.com/group/enzo-dev.
For more options, visit https://groups.google.com/d/optout.

Yusuke Fujimoto

unread,
Oct 19, 2016, 3:33:01 AM10/19/16
to enzo-dev
I modified slug.H, and it works.
Thank you!!

Yusuke
Reply all
Reply to author
Forward
0 new messages