ThrowTheSwitch / CMock

CMock - Mock/stub generator for C
http://throwtheswitch.org
MIT License
653 stars 269 forks source link

Mocking inline functions option destroying include files with no inline functions #382

Closed kamal-ahmed-emphysys closed 3 months ago

kamal-ahmed-emphysys commented 2 years ago

I am using Cmock option for mocking inline functions. The option for mocking externs in not set (default). Not sure what is triggering the inline treatment. Plus, even if there was an inline function here, I did not expect the macros and the included file to be removed in the replacement. I am also surprised that the parser does not generate header guards.

I have included the original file and generated replacement. The included file for macro magic and the macros should be irrelevant to the parser.

Original:

/*

include "vartypes.h"

include "global_defines.h"

undef VAR

undef STRUCT

define VAR( type, name, init, fname ) type name ;

define STRUCT( type, ref ) struct _##type *ref ;

//!Typedef for structure that contains all variables in the control structure typedef struct _control_t {

include "controlvars.h"

} control_t;

undef VAR

undef STRUCT

extern control_t control_def;

int control_update( void );

void control_init( void );

void control_halt( void );

endif

Replacement generated by Cmock:

include "../CM7/controlvars.h"

include "../CM7/global_defines.h"

include "../CM7/base/vartypes.h"

typedef struct _control_t {

} control_t;

extern control_t control_def;

int

control_update( void );

void

control_init( void );

void

control_halt( void );

laurensmiers commented 2 years ago

Are you using cmock with ceedling? If so, there is a known issue with the test preprocessor (see https://github.com/ThrowTheSwitch/CMock/issues/328). But I don't know why the inline mocking is enabled, it is disabled by default.

M-Bab commented 1 year ago

Please check if this is the problem described here: https://github.com/ThrowTheSwitch/Ceedling/issues/706#issuecomment-1380244582

mvandervoord commented 3 months ago

duplicate inline function issues.