Kconfiglib icon indicating copy to clipboard operation
Kconfiglib copied to clipboard

Extension Suggestion: Strings without quotation marks (Macro-like)

Open tito97sp opened this issue 1 year ago • 0 comments

Title: Proposal to Enhance C Preprocessor Redefinition Strings Generation

Objective:

This proposal suggests an extension to enhance the functionality of generating C Preprocessor redefinition strings without quotation marks in order to provide more flexibility and convenience in defining C macros.

Rationale:

In certain scenarios, it becomes necessary for a module to redefine a C Preprocessor Macro to another symbol. However, the current implementation in kconfiglib utilizes the string type, which always generates a string with quotation marks. This limitation restricts the flexibility and usability of the tool.

Current Status:

The current version of kconfiglib only supports generating C Preprocessor redefinition strings with quotation marks. For instance:

#define CONFIG_FUNCTION_CALLBACK_NAME "MyFunctionCallback"

Proposed Solution:

Modify the kconfig for supporting another type (example: macro type):

config CONFIG_FUNCTION_CALLBACK_NAME
    macro "Set the name of the callback function"
    default "MyFunctionCallback"
    help
      This will generate the preprocessor macro for the function callback name.

The proposed extension aims to introduce the capability to generate C Preprocessor redefinition strings without quotation marks, as demonstrated in the following example:

#define CONFIG_FUNCTION_CALLBACK_NAME MyFunctionCallback

This enhancement will enable developers to define macros more conveniently and provide greater flexibility in their code implementations. For example:


void CONFIG_FUNCTION_CALLBACK_NAME(void)
{
   ....
}

Benefits:

  • Improved Capability: The proposed extension enhances the tool's functionality by enabling the generation of C definitions without quotation marks, allowing for more versatile macro definitions.

tito97sp avatar Jun 09 '23 12:06 tito97sp