So why do the types conflict? They're all the same!

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm beginning to think I'm right about C

uint8_t DeviceSig[11] ;

uint8_t ReadSignatureByte(uint16_t Address) 
{
   I'd love to show you the code but the stupid forum software complains, "Bad request." Forum must be written in C or something.
}

void SomethingElse(void)
{
	enum {
		LOTNUM0=8,  // Lot Number Byte 0, ASCII
		LOTNUM1,    // Lot Number Byte 1, ASCII
		LOTNUM2,    // Lot Number Byte 2, ASCII
		LOTNUM3,    // Lot Number Byte 3, ASCII
		LOTNUM4,    // Lot Number Byte 4, ASCII
		LOTNUM5,    // Lot Number Byte 5, ASCII
		WAFNUM =16, // Wafer Number
		COORDX0=18, // Wafer Coordinate X Byte 0
		COORDX1,    // Wafer Coordinate X Byte 1
		COORDY0,    // Wafer Coordinate Y Byte 0
		COORDY1,    // Wafer Coordinate Y Byte 1
	};

	DeviceSig[ 0]=ReadSignatureByte(LOTNUM0);
}

It says types conflict for DeviceSig on the assignment to DeviceSig[ 0]. They look mighty the same to me.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can't put a statement outside of a function like that.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Compiles fine for me with gcc -pedantic -std=c99. Maybe your compiler has some strict non-conforming mode where it doesn't implicitly convert enumeration constants to integers. If your ReadSignatureByte function only accepts those enumerations, you can have it take an enumeration type (how enum was meant to be used):

enum address_t {
  LOTNUM0=8,  // Lot Number Byte 0, ASCII
  LOTNUM1,    // Lot Number Byte 1, ASCII
  ...
};

uint8_t ReadSignatureByte(enum address_t Address)

#define can still be used if you don't work it out:

#define LOTNUM0 8
#define LOTNUM1 9
...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I'd love to show you the code but the stupid forum software complains, "Bad request."

How on Earth can you have missed that the forum dislikes percent-signs under some circumstances?!?

As always show a minimal but complete program that demonstrates the problem.

The forum software is written in PHP.

Quote:
It says types conflict for DeviceSig on the assignment to DeviceSig[ 0]

blargg has a good point: Is it the assignment to DeviceSig[0] that is the problem, or is it the passing of the parameter to the function?

Quote:
I'm beginning to think I'm right about C

Interesting conclusion.. So every time you struggle understanding something it is something wrong with what you are studying?

(Not that C is perfect. Just ask Jan.. :wink:)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So, I copied the code fresh from the app where I initially designed it back into my library folder, re-edited it, and now C agrees with me that a uint8_t is a uint8_t.

"It's your language. I'm just trying to use it." -- Victor Borge

Quote:

(Not that C is perfect. Just ask Jan.. )

You haven't seen my "C Bash" in Amin's thread about improving his code?

So it's percent signs that confuse the forum software? I'll prolly not recognize it next time it says I'm asking for a bad thing.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut.