Project

General

Profile

Feature #2038

Replace `define` with `static const ...` where possible

Added by rhargrave almost 5 years ago. Updated 3 months ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
Enhancement
Target version:
-
Start date:
2015-05-06
% Done:

0%


Description

In working on various bits of doomsday, I noticed that macros are quite often used where constants could be used. I think that it might be an interesting idea to see about replacing as many macros as possible with real constant symbols, as there no longer appears to any need for compatibility with extremely old versions of C. This could make debugging easier (as macros are not included in debugging symbols, whereas constant declarations are), and could vastly increase code quality by eliminating situations like this:

void function(void)
{
#define MACRO value
    code;
    code;
    code;
#undef MACRO
}

History

#1 Updated by rhargrave almost 5 years ago

  • Tags set to CodeQuality, Code, Developer

#2 Updated by skyjake 3 months ago

  • Status changed from New to Closed

This is good advice, and recent code already does it this way.

Closing as acknowledged.

Also available in: Atom PDF