Compile error (ISO C++ comparison)

Hi everyone,

So I am in the middle of writing support for moving lines in an engine I'm authoring based on the DOOM code.

While cross compiling, I get a few errors, all related:

src/p_poly.cc: In function 'void PO_SpawnPolyobj(float, float, int, int)':
src/p_poly.cc:643:36: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    if (segs[i].linedef->special == PO_LINE_START &&
                                    ^
src/p_poly.cc:688:35: error: expected ')' before 'PO_LINE_START'
     if (segs[i].linedef->special  PO_LINE_START &&
                                   ^
src/p_poly.cc:716:37: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
     if(segs[i].linedef->special  == PO_LINE_EXPLICIT  &&
                                     ^
src/p_poly.cc:732:39: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
      if (segs[i].linedef->special  == PO_LINE_EXPLICIT  &&
                                       ^
make: *** [obj_win32/edge/p_poly.o] Error 1


So basically, I'm getting an error with the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 ...
	polyobjs[index].startSpot.x = x;
	polyobjs[index].startSpot.y = y;
	for (i = 0; i < numsegs; i++)
	{
		if (!segs[i].linedef)
			continue;
		// Next line results in a compile error 
			if (segs[i].linedef->special == PO_LINE_START &&
			segs[i].linedef->arg1 == tag)
		{
			if (polyobjs[index].segs)
			{
            	//	Immpossible, because it is just cleared out
				I_Error("PO_SpawnPolyobj:  Polyobj %d already spawned.\n", tag);
			}
...

All "errors" are of that type (defined 3 times in the source file).

At the top of the source file, I have the following:

1
2
static const int PO_LINE_START = 1;
static const int PO_LINE_EXPLICIT = 5;



I'm not sure why it's failing here, any advice is greatly appreciated =) It's causing me to pull my hair out! Basically it needs to know that if a linedef special is marked as PO_LINE_START or PO_LINE_EXPLICIT, that it is free to "spawn" the object. If I comment those lines out, the code compiles, but the engine will not spawn because there is no explicit special for PO_LINE_x defined.

Thanks for your help <3
Last edited on
It sounds like you need to deference your pointer data to a value before you do your comparison. And also


1
2
3
4
 * not vaild
    if((a != b && c = d)){
      // do things  
    }


where

1
2
3
4
  vaild
    if((a != b) && (c = d)){
      // do things  
    }


Where the above is causing the ": error: expected ')' before 'PO_LINE_START'"
Last edited on
Thank you! Can't believe I missed the expected ')' error, it's been a long day :S

What's the best way to dereference the pointer data to a value (maybe an example)? I really appreciate the help :)
no prob. Your really going to like this one :)

1
2
3
4
5
6
7
8
    // using dereference  operator '*'
    if (*ptrVal = 5) {
        std::cout << "true" << std::endl;

    } else {
        std::cout << "false" << std::endl;

    }
Last edited on
Topic archived. No new replies allowed.