This may seem like a simple question but i am getting an error when compiling this. I want to be able to pass an enum into a method in C.
Enum
enum TYPES { PHOTON, NEUTRINO, QUARK, PROTON, ELECTRON };
Calling the method
makeParticle(PHOTON, 0.3f, 0.09f, location, colour);
Method
struct Particle makeParticle(enum TYPES type, float radius, float speed, struct Vector3 location, struct Vector3 colour)
{
struct Particle p;
p.type = type;
p.radius = radius;
p.speed = speed;
p.location = location;
p.colour = colour;
return p;
}
The error I am getting is when I am calling the method:
incompatible types in assignment
It compiles fine for me, in this cut-down example:
Are you sure that you’ve made the declaration of
TYPESavailable to the code in both the definition ofmakeParticleand the call to it? It won’t work if you do this:because the
main()code hasn’t seen TYPES yet.