CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Weird CCS compiler thing: getenv("CONFIGURATION_ADDRESS

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
allenhuffman



Joined: 17 Jun 2019
Posts: 580
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

Weird CCS compiler thing: getenv("CONFIGURATION_ADDRESS
PostPosted: Thu Dec 19, 2024 11:18 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group