Reply by "Max...@gmail.com [msp430]"●July 26, 20142014-07-26
Thinking back years: The compiler inserts the null when it recognizes the
quotation marks are used. The preprocessor is running before that step has
completed.
-Max Murphy
On Tue, Jul 15, 2014 at 1:36 AM, 'Steve Mayfield' S...@att.net
[msp430] wrote: > Maybe the quick watch uses strlen() which would
return 4.
>
> *From:* mailto:m...
> *Sent:* Monday, July 14, 2014 5:39 PM
> *To:* m...
> *Subject:* [msp430] Re: Defined string with 4 characters is sizeof 4 in
> watch and 5 in compiled code.
>
> Ok, so 4 chars and a null, but then why does the debugger in the quick
> watch window, report that it is 4?
>
>
>
Reply by "'Bi...@cdivia.com [msp430]"●July 15, 20142014-07-15
If IAR assumes 32-bit data pointers, watch may be showing the size of the
address of the string.
Does watch sizeof("longer string") show 4, 13, or 14?
Reply by "'St...@att.net [msp430]"●July 15, 20142014-07-15
Maybe the quick watch uses strlen() which would return 4.
From: mailto:m...
Sent: Monday, July 14, 2014 5:39 PM
To: m...
Subject: [msp430] Re: Defined string with 4 characters is sizeof 4 in watch and
5 in compiled code.
Ok, so 4 chars and a null, but then why does the debugger in the quick watch
window, report that it is 4?
Reply by "jam...@massmind.org [msp430]"●July 14, 20142014-07-14
Ok, so 4 chars and a null, but then why does the debugger in the quick watch
window, report that it is 4?
Reply by "Pet...@sensair.com [msp430]"●July 14, 20142014-07-14
Possibly 4 chars and a terminating null, '\0' ?
PL
---
This email is free from viruses and malware because avast! Antivirus protection
is active. http://www.avast.com
Posted by: Peter Lissenburg
Reply by "jam...@massmind.org [msp430]"●July 14, 20142014-07-14
Not unless you put a \0 on it. And even if that is so, why does the debugger say
it's 4 long?
Reply by "'St...@att.net [msp430]"●July 14, 20142014-07-14
Strings include a NUL character as the string terminator. So that would be
4+1
----- Original Message -----
From: j...@massmind.org [msp430]
To: m...
Sent: Monday, July 14, 2014 16:38
Subject: [msp430] Defined string with 4 characters is sizeof 4 in watch and 5
in compiled code.
So, just out of curiosity, how can
sizeof(LOGGER_SERIAL_DEFAULT)
be both 4 (in the QuckWatch) and 5 in the compiled code (red line in
disassembly) ?
It's defined as:
#define LOGGER_SERIAL_DEFAULT "----"
So in my mind it should be 4 (if the compiler wanted to count the quotes it
would be 6) but NEVER 5.