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.
http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/166/0552.delme.png
http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/166/0552.delme.png
http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/166/0552.delme.png
http://e2e.ti.com/cfs-file.ashx/__key/communityserv...
http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/166/0552.delme.png
View on e2e.ti.com
http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/166/0552.delme.png
Preview by Yahoo
Defined string with 4 characters is sizeof 4 in watch and 5 in compiled code.
Started by ●July 14, 2014
Reply by ●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.
http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/166/0552.delme.png
http://e2e.ti.com/cfs-file.ashx/__key/communityserv...
View on e2e.ti.com Preview by Yahoo
----- 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.
http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/166/0552.delme.png
http://e2e.ti.com/cfs-file.ashx/__key/communityserv...
View on e2e.ti.com Preview by Yahoo
Reply by ●July 14, 20142014-07-14
Reply by ●July 14, 20142014-07-14
Possibly 4 chars and a terminating null, '\0' ?
PL
On 15/07/2014 9:38 AM, j...@massmind.org [msp430] wrote:
> 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.
> http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/166/0552.delme.png
>
>
> image
>
>
> http://e2e.ti.com/cfs-file.ashx/__key/communityserv...
>
> View on e2e.ti.com
>
> Preview by Yahoo
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
Posted by: Peter Lissenburg
PL
On 15/07/2014 9:38 AM, j...@massmind.org [msp430] wrote:
> 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.
> http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/166/0552.delme.png
>
>
> image
>
>
> http://e2e.ti.com/cfs-file.ashx/__key/communityserv...
>
> View on e2e.ti.com
>
> Preview by Yahoo
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
Posted by: Peter Lissenburg
Reply by ●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 ●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?
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 ●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?
address of the string.
Does watch sizeof("longer string") show 4, 13, or 14?
Reply by ●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?
>
>
>
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?
>
>
>