in Education by
Say you want to generate a matched list of identifiers and strings enum { NAME_ONE, NAME_TWO, NAME_THREE }; myFunction(NAME_ONE, "NAME_ONE"); myFunction(NAME_TWO, "NAME_TWO"); myFunction(NAME_THREE, "NAME_THREE"); ..without repeating yourself, and without auto-generating the code, using C/C++ macros Initial guess: You could add an #include file containing myDefine(NAME_ONE) myDefine(NAME_TWO) myDefine(NAME_THREE) Then use it twice like: #define myDefine(a) a, enum { #include "definitions" } #undef myDefine #define myDefine(a) myFunc(a, "a"); #include "definitions" #undef myDefine but #define doesn't let you put parameters within a string? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
For your second #define, you need to use the # preprocessor operator, like this: #define myDefine(a) myFunc(a, #a); That converts the argument to a string.

Related questions

0 votes
    A ___________________ is an explicit numeric, character, string or Boolean value not represented by an identifier ... in section Query Processing Techniques of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    What is the maximum length of an identifier in C?...
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    In __________, each external request is tagged with a unique identifier which is passed to all services involved ... . Distributed tracing C. Application logging D. Audit logging...
asked Jan 11, 2023 in Education by JackTerrance
0 votes
    There are similarities between the instructor entity set and the secretary entity set in the sense that ... Database Systems Design and Implementation of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    In __________, each external request is tagged with unique identifier which is passed to all services involved in ... b)Audit logging (c)Application logging (d)Exception tracing...
asked Oct 21, 2020 in Technology by Editorial Staff
0 votes
    What is the order of namespaces in which Python looks for an identifier? a) Python first searches the built-in ... , then the local namespace and finally the built-in namespace...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    Which of the below is invalid identifier with the main method? (a) public (b) static (c) private ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    Which identifier is used to represent a web browser window or frame? (a) frames (b) window (c) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    ____________ is a Universal Unique Identifier that identifies a particular FlowFile from another FlowFile in the system. (1)uname (2)user (3)uuid (4)All the options...
asked Apr 18, 2021 in Technology by JackTerrance
0 votes
    Where & how do you code Identifier in JCL? A - /* starting from column 1 B - / starting from column 1 C - // starting from column 1 D - None of these...
asked Dec 4, 2020 in Technology by JackTerrance
0 votes
    Cost saving is possible in networking due to: (a)Data sharing (b) Software sharing (c) Both i and ii (d)None of these Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    Which types of organization used income and expenditure Statement (a) business (b) School (c) both (d) none Select the correct answer from above options...
asked Dec 23, 2021 in Education by JackTerrance
0 votes
    Write C program that use both recursive and non recursive functions to perform Linear search for a Key value in a given list. Select the correct answer from above options...
asked Dec 17, 2021 in Education by JackTerrance
0 votes
    Can we declare a variable be both constant and volatile in C?...
asked Jan 23, 2021 by JackTerrance
...