allenhuffman
Joined: 17 Jun 2019 Posts: 580 Location: Des Moines, Iowa, USA
|
Weird CCS compiler thing: getenv("CONFIGURATION_ADDRESS |
Posted: Thu Dec 19, 2024 11:18 am |
|
|
Here is a fun one -- discussing it with CCS currently:
These work just fine (DEBUG_PRINTF is printf):
Code: |
#include <inttypes.h> for the PRIx32 stuff:
DEBUG_PRINTF ("PROGRAM_MEMORY : 0x%" PRIx32 " (%lu)\r\n",
getenv("PROGRAM_MEMORY"), getenv("PROGRAM_MEMORY"));
|
But when I tried do use the other one, it won't build:
Code: |
DEBUG_PRINTF ("CONFIGURATION_ADDR. : 0x%" PRIx32 " (%lu)\r\n",
getenv("CONFIGURATION_ADDRESS"), getenv("CONFIGURATION_ADDRESS"));
|
Some experimenting led me to loading it in to a variable and then printing the variable, and that worked. But, oddly, this also works:
Code: |
int x = getenv("CONFIGURATION_ADDRESS");
DEBUG_PRINTF ("CONFIGURATION_ADDR. : 0x%" PRIx32 " (%lu)\r\n",
getenv("CONFIGURATION_ADDRESS"), getenv("CONFIGURATION_ADDRESS"));
|
Though that gives me an un-used variable warning.
Just odd. Thought I'd pass this along and see if anyone else has run into it.
(And it started with just %x and %u, on a 64K part, but CCS thought it might need %lx and %lu, and then I made the change using the inttypes.h stuff.
(If you aren't familiar with inttypes.h -- I wasn't either. I only learned of it recently: https://subethasoftware.com/2024/09/30/printf-portability-problems-persist-possibly/ _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ?
Using: 24FJ256GA106, 24EP256GP202 and 24FJ64GA002. |
|