Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Convert "invalid" characters to underscore
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Hvergelmir
Junior Member

11 Posts

Posted - Aug 21 2018 :  11:06:48 AM  Show Profile  Reply with Quote
I am using the following alternative to the shipped ifdef header guard.

#ifndef __$FILE_BASE_UPPER$_$FILE_EXT_UPPER$_VER__
#define __$FILE_BASE_UPPER$_$FILE_EXT_UPPER$_VER__ $YEAR$$MONTH_02$$DAY_02$$HOUR_02$
#if (defined(_MSC_VER) && (_MSC_VER >= 1020)) || defined(__MCPP)
#pragma once
#endif /* Check for "#pragma once" support */

$selected$
#endif /* __$FILE_BASE_UPPER$_$FILE_EXT_UPPER$_VER__ */


However, you can probably already tell the issue here. Say I have a header file named foo-bar.h the outcome of the first line when "rendered" will be:

#ifndef __FOO-BAR_H_VER__

... all fine, except for the hyphen in the name. It would be great if there was some kind of filter I could apply to these built-in variables in order to convert hyphens and other characters that would be invalid inside identifiers into underscores. Either some kind of "filter function" or alternative versions of the built-in variables would be great for the purpose.

Thanks.

feline
Whole Tomato Software

United Kingdom
18755 Posts

Posted - Aug 21 2018 :  4:15:34 PM  Show Profile  Reply with Quote
I had never actually considered this, since nearly all of my file names are also safe identifier names, an old habit I must have picked up somewhere along the line. But trying this, I can use several unhelpful characters in a Windows filename. I have put in a feature request for new versions of the FILE tokens that are identifier character safe:

case=118582

zen is the art of being at one with the two'ness
Go to Top of Page

Hvergelmir
Junior Member

11 Posts

Posted - Aug 22 2018 :  06:19:05 AM  Show Profile  Reply with Quote
Thanks. Yeah, there's a whole bunch of them. I guess whenever one uppercases the whole file name using this method the intention is to use it as some kind of identifier or similar. But perhaps there are other reasons I haven't considered :)

In an ancient code base I work on, developers (unhelpfully, I may add) have decided to stick to 8.3 DOS file names as the maximum (only ASCII digits and letters allowed, a dot to separate the extension and the extension itself). Since one of the developers is working on this code for nearly 30 years, he gets to make that call, though.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18755 Posts

Posted - Aug 22 2018 :  08:13:09 AM  Show Profile  Reply with Quote
I had always suspected upper casing the filename was to do with complying with standards for comment blocks at the start of a file. It obviously depends on what random things you have seen over the years, and different people see different random things.

Short filenames feel limiting, but if grouped sensibly by directory they don't have to be a problem. At least it avoids ending up with stupidly long filenames, which I have also seen happen

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000