From: SourceForge.net <no...@so...> - 2008-08-05 00:07:02
|
Feature Requests item #1961855, was opened at 2008-05-11 14:12 Message generated for change (Comment added) made by maurogiachero You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=350599&aid=1961855&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Priority: 5 Private: No Submitted By: Andreas Czechanowski (acz) Assigned to: Nobody/Anonymous (nobody) Summary: pic16: use for binary constants (0b00110101) Initial Comment: For porting of source written for the Microchip MCC18, the possibility of writing binary constants starting with 0b... (equivalent to 0x... for hex) is appreciated. Although this does not confirm to C-standards, it might be useful for other architectures as well. Regards, Andreas. ---------------------------------------------------------------------- Comment By: Mauro Giachero (maurogiachero) Date: 2008-08-05 02:06 Message: Logged In: YES user_id=2160854 Originator: NO A new revised patch is now available: https://sourceforge.net/tracker/index.php?func=detail&aid=2038174&group_id=599&atid=300599 Mauro ---------------------------------------------------------------------- Comment By: Borut Raem (borutr) Date: 2008-08-04 20:26 Message: Logged In: YES user_id=568035 Originator: NO Mauro, don't forget to prepare the patch for the documentation (sdccman.lyx, ...) too. Borut ---------------------------------------------------------------------- Comment By: Mauro Giachero (maurogiachero) Date: 2008-08-03 22:57 Message: Logged In: YES user_id=2160854 Originator: NO Thank you all for the notes and the words pro/con this patch, and to Borut for pointing out the pieces I missed (sorry about that!). Since the global feeling about this topic seems to get better, in the next days I'll try to cook up a patch fixing all the things emerged in this thread. Mauro ---------------------------------------------------------------------- Comment By: Borut Raem (borutr) Date: 2008-07-31 23:40 Message: Logged In: YES user_id=568035 Originator: NO I'm slowly changing the opinion too, mainly since the BIN macro is not so "perfect" as it seemed at the first glance: it works only on 8 bit values (it could be extend to 11 bits using octal notation instead hexadecimal, but it doesn't help much...) I took a quick look to the patch and I noticed that there is missing the sdcpp part: the file support/cpp/libcpp/lex.c, function pedantic_lex_number() should be modified too. And again: it should be enabled only under --std-sdccXX and disabled under --std-cXX. There should be a fix to pass the correct -std=XXX parameter, depending on --std-XXX sdcc parameter, to sdcpp: currently sdcpp semms to be always called with -std=c99, no matter what --std-XXX option was defined on sdcc command line... Borut ---------------------------------------------------------------------- Comment By: Patryk (patryks) Date: 2008-07-31 09:25 Message: Logged In: YES user_id=1788180 Originator: NO Metrowerks (now Freescale) CodeWarrior for HC(S)08 also supports it from at least version 3.1 (but not in 2.1). Anyway I never used it. "Binary Constants (0b) Use binary notation for constants instead of hexadecimal constants or normal constants. Note that binary constants are not allowed if the -Ansi: Strict ANSI compiler option is switched on. Binary constants start with the 0b prefix, followed by a sequence of zeroes or ones. #define myBinaryConst 0b01011" ---------------------------------------------------------------------- Comment By: Mauro Giachero (maurogiachero) Date: 2008-07-30 19:03 Message: Logged In: YES user_id=2160854 Originator: NO I didn't know about GCC either, so I can't really use that as an "excuse"... Mauro ---------------------------------------------------------------------- Comment By: Mauro Giachero (maurogiachero) Date: 2008-07-30 18:56 Message: Logged In: YES user_id=2160854 Originator: NO No offense at all, really! I certainly don't think that a couple of bug fixes give me the right of deciding whether a feature must be accepted or not. About the other compilers having this feature, I used in the past Hi-Tech PICC and MELabs Pic Basic Pro in PIC14 projects, and both have binary constants. I used that feature a lot on initialization, when different bits of a single byte can have completely different meanings. Having this feature enabled only under --std-sdccXX can be a good idea. I can certainly look at it, but I'd like to see some consensus about the decision of applying it once done (so little time, so many things to do!). Mauro ---------------------------------------------------------------------- Comment By: Frieder Ferlemann (frief) Date: 2008-07-30 18:47 Message: Logged In: YES user_id=589052 Originator: NO Hi, I was not aware that GCC also supports this binary notation. >From http://gcc.gnu.org/gcc-4.3/changes.html : "Integer constants written in binary are now supported as a GCC extension. They consist of a prefix 0b or 0B, followed by a sequence of 0 and 1 digits." So I retract my objection - thanks and apologies to Mauro! Greetings, Frieder ---------------------------------------------------------------------- Comment By: Borut Raem (borutr) Date: 2008-07-30 18:16 Message: Logged In: YES user_id=568035 Originator: NO I agree that it could be enabled only under --std-sdccXX, but on my opinion it just introduces the confusion. I just expressed my personal opinion. If somebody thinks that the feature is indispensable, feel free to apply the patch, probably with the modification that the feature is active only under --std-sdccXX. Mauro, I hope I didn't offend you. Thank you for your great patches! Borut ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2008-07-30 12:11 Message: Logged In: YES user_id=888171 Originator: NO First let me say that I would not have any problem with this feature implemented in SDCC. I don't believe it results in "vendor lock in" because it's entirely up to the user to use it or not. You can always use strict ANSI/ISO C without penalty. But I would only want it enabled under --std-sdccXX. OTOH I have no problem with rejecting the feature and keeping it out of SDCC either. I did some some searching about your claim that all other compilers for microcontrollers support this feature. I could find only GCC. The others (IAR, Keil, ARM) do not support this. I agree that it should have been in the spec but that is outside of my control. Maarten ---------------------------------------------------------------------- Comment By: Mauro Giachero (maurogiachero) Date: 2008-07-30 10:02 Message: Logged In: YES user_id=2160854 Originator: NO I'm fine with the reject decision, as the patch is available anyway for those who really want that feature. And I didn't know about the macro, sorry. I feel nevertheless that the "lock-in" argument is weak: all compilers targeting microcontrollers I know about (not many, all commercial) have this feature, and while I'm certainly biased about this I always felt that it not being ANSI C is somewhat a lack of the specification. Anyway as I said I'm fine with the reject. And thank you for writing/maintaining/... sdcc! With best regards Mauro ---------------------------------------------------------------------- Comment By: Borut Raem (borutr) Date: 2008-07-29 22:36 Message: Logged In: YES user_id=568035 Originator: NO I agree with Frieder: this is not an ANSI C standard feature and sdcc tends to be ANSI C compliant. And there is an excellent macro provided by Bernhard, which fills the gap. Borut ---------------------------------------------------------------------- Comment By: Frieder Ferlemann (frief) Date: 2008-07-29 21:27 Message: Logged In: YES user_id=589052 Originator: NO Hi, sorry to say: I don't like this idea: It can be seen as a kind of "vendor lock in" (providing features that an ANSI-C compiler does not have) And (slightly inflamatory) if you like the idea you might have been exposed to this kind of "vendor lock in" :^) There has been related discussion about this (at least) here (sorry, both the search function on Sourceforge and its web interface to list/forums seem disfunctional at the moment, so it seems I cannot provide direct links) 2007-02-17 [Sdcc-user] binary representation of integer? 2007-06-18 [Sdcc-user] How to express binary number in SDCC? 2007-05-29 [sdcc - Open Discussion] binary constant and preprocessor workarounds have been (at least) proposed here: http://sourceforge.net/tracker/index.php?func=detail&aid=882215&group_id=599&atid=350599 http://sourceforge.net/forum/message.php?msg_id=4334535 Please do not apply. ---------------------------------------------------------------------- Comment By: Mauro Giachero (maurogiachero) Date: 2008-07-29 00:30 Message: Logged In: YES user_id=2160854 Originator: NO Addressed by patch 2030780 at http://sourceforge.net/tracker/index.php?func=detail&aid=2030780&group_id=599&atid=300599 Mauro Giachero ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=350599&aid=1961855&group_id=599 |