0

Hi, I have a bunch of hex constants I'd like to define with new names for characters for an LCD driver I'm writing.

Can I just define them in hex in the header like this:

#define NINE 0x39

Do I have to force #define statements into char like this?

#define NINE (char)0x39

will the hex work in the #define declaration or do I have to use decimal numbers like this:

#define NINE (char)63

I'd like to keep it hex if possible.


Thanks for any help in advance, Glen.

3
Contributors
6
Replies
8
Views
6 Years
Discussion Span
Last Post by WaltP
0

Ok great. Does it store as a char? Or is that program specific?

0

Thought so, I was hoping I could force it to be a char...

You could cast it to character.

#include <stdio.h>

#define NINE (char)0x39

int main()
{
  fprintf(stdout, "%c %lu\n", NINE, sizeof(NINE));
  return 0;
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.