Jump to content

Set parameter


Deepika Rajput

Recommended Posts

Hello All,

 

I want to implement the condition or a function that would only be executed if Parameter (used to define it) to 1 otherwise if 0 it won't be executed or even exists in the program.

 

So to say COMMENT A FUNCTION USING PARAMETER.

 

For instance like 

 

Class XYZ: public sc_module {

 

---------

----------------

----------------------

[group of functions]

 

}

 

Void function_definition () {

inst 1

inst 2 

PRINT_MY_DEBUG (any arguments);

 

This PRINT_MY_DEBUG is only required suppose when I need to debug else not .

 

So I want configure the condition whether to allow or not this PRINT_MY_DEBUG using some parameter from top.

 

I think I am clear for my questions, else please notify and reply.

Link to comment
Share on other sites

If I understand you correctly, you want to have a preprocessor switch:

 

#if defined(DEBUG)
#  define PRINT_MY_DEBUG( Some, Args ) \
    print_debug_impl( (Some), (Args) )
#else
#  define PRINT_MY_DEBUG( Some, Args ) \
    ((void)0) /* empty statement */
#endif // DEBUG

void print_debug_impl( ... ); // real function implementation

 

In the example above, the preprocessor symbol DEBUG is checked, whether or not to enable calls to the print_debug_impl function through the PRINT_MY_DEBUG function macro. You can define such symbols in the source, or via the command-line of your compiler (usually "-D<symbol>[=<value>]", i.e. here -DDEBUG).

 

hth,
  Philipp

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...