Jump to content
Deepika Rajput

Set parameter

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×