Simple C question...entering binary

The Ada-style "_" spacer in numbers (for hex and decimal as well as bin) would be a huge improvement to readability for longer strings. It should also appeal to the "hosted" folk as well as the "non-hosted" folk, so perhaps Walter might have some luck suggesting it to the powers that be in the C world.

Reply to
David Brown
Loading thread data ...

I was used to PL/M's "$" null separator, which let me write

VALUE = 0100$1100B;

or something like that. This was circa 1988. When I switched to C, I was surprised to see no "B" nor "$" equivalent forms. I agree, though, that Ada's "_" is far superior.

Reply to
Ignacio G.T.

I like the spacer syntax. There is at least one C compiler that supports spacers (not ours) I don't think that spacer syntax is likely to be introduced into C anytime soon. C has never had it and there are some things that need to be resolved long before this becomes a pressing issue.

In our case we added 0B... , 0b.... with the same syntax as hex support. I recognize the argument for hex support only and legacy support for octal notation. My customers are almost all non-hosted embedded systems folks and we have supported their needs with the extension.

Walter Banks Byte Craft Limited

Reply to
Walter Banks

I would think the spacer idea could be adopted faily readily since it's upward (forward?) compatible and is nearly trivial to implement.

Now, for a real miracle, get them to revise some of the string functions to return something useful. Who has any need for the first arg to strcpy() as the return value?

Reply to
Everett M. Greene

Slow imagination? This popped immediately to mind (I'm sure a compiler writer will provide better.) Consider the ?: syntax for a moment and how it _might_ be used.

Jon

Reply to
Jonathan Kirwan

of:

In my opinion, the interesting downside of mnemonics is that you have t get it right twice; right with the definition of the mnemonic (in your . file or wherever), and right in its usage. Also, it isn't as clear whe you read the code. I'd rather see a hex literal than a mnemonic; at leas I can directly reference the register bit settings from a hardware devic data sheet rather than finding the mnemonic definition in a .H file, the doing the reference.

Jeff

formatting link

Reply to
JeffR

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.