 | Discussion Forum |  |
|
|
Problem with string substitution using C51 define directiveNext Thread | Thread List | Previous Thread Start a Thread | Settings | Details | Message |
|---|
Read-Only Author kok hua tan Posted 28-Nov-2009 13:26 GMT Toolset C51 |  Problem with string substitution using C51 define directive kok hua tan I'm trying to pass a string using the C51 DEFINE directive from command line. i.e. DEFINE(SERIAL="FOOBAR") When compiling, it is converted to an identifier (FOOBAR) instead of remaining as a string literal ("FOOBAR"). Is there a way to force it to remain as a string literal? | | Read-Only Author Hans-Bernhard Broeker Posted 28-Nov-2009 20:15 GMT Toolset C51 |  RE: Problem with string substitution using C51 define directive Hans-Bernhard Broeker How are you passing that command line to C51? Are you sure the tool you're using for that (cmd shell, IDE, Makefile, ...) isn't stripping the quotes, believing they were meant for that tool to deal with, rather than C51? Probably the easiest way of checking this is in the list files: at their top they document the actual command line C51 was invoked with. See if the quotes survived until that point. If it didn't, you need to check your other tools. Quotes are notoriously tricky to pass into C compilations from the outside --- every 'make', IDE, and compiler has its own quirk. So odds are you would be better off checking hard if you really need to do this at all. The stringization operator of the preprocessor (#macro) might help you work around that. | | Read-Only Author Andy Neil Posted 28-Nov-2009 23:57 GMT Toolset None |  Quotes are notoriously tricky to pass Andy Neil Yes, I have had problems with the (mis)interpretation of quotes by uVision. It was a long time ago - I have no idea if it's been fixed... | | Read-Only Author kok hua tan Posted 29-Nov-2009 12:24 GMT Toolset C51 |  RE: Quotes are notoriously tricky to pass kok hua tan Look at the list file, the quotes are indeed stripped by the compiler. Try to use backslash '\' on Makefile, command line, and IDE, but it still don't work on all cases. The compiler just strip the quote. | | Read-Only Author Andrew Neil Posted 29-Nov-2009 13:40 GMT Toolset None |  RE: the quotes are indeed stripped by the compiler Andrew Neil It's not necessarily the Compiler that's doing it - it might be uVision stripping the quotes before they get to the compiler...? Or it might be something else that happens betwen uVision and the compiler... Have you tried doubling-up the quotes; eg, DEFINE(SERIAL=""FOOBAR"") | |
Next Thread | Thread List | Previous Thread Start a Thread | Settings |
|