ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects
http://throwtheswitch.org
Other
587 stars 246 forks source link

[Bug] "Failed Parsing Declaration Prototype!" #429

Open Darker7 opened 4 years ago

Darker7 commented 4 years ago

The error

I am working with the OPC UA implementation open62541 as a dependency and as such I would of course like to mock it when defining the behaviour of my code. Thing is, when I try to run tests:all to generate "mock_open62541.h" I get this error:

Failed Parsing Declaration Prototype!
  declaration: 'UA_Client_Subscriptions_new(UA_Client *client, UA_SubscriptionSettings settings, UA_UInt32 *newSubscriptionId)'
  modifier: ''
  return: {:type => '', :name => 'cmock_to_return', :str => ' cmock_to_return', :void? => false, :ptr? => false, :const? => false, :const_ptr? => false}
  function: 'UA_Client_Subscriptions_new'
  args: [
    {:ptr? => true, :const? => false, :const_ptr? => false, :name => 'client', :type => 'UA_Client*'}
    {:ptr? => false, :const? => false, :const_ptr? => false, :name => 'settings', :type => 'UA_SubscriptionSettings'}
    {:ptr? => true, :const? => false, :const_ptr? => false, :name => 'newSubscriptionId', :type => 'UA_UInt32*'}
  ]

The problem

So I started digging and quickly found what appears to be the problem: the parser doesn't take return type definitions in the previous line into account.
See the offending source code:

UA_DEPRECATED UA_StatusCode UA_EXPORT
UA_Client_Subscriptions_new(UA_Client *client, UA_SubscriptionSettings settings,
                            UA_UInt32 *newSubscriptionId);
mvandervoord commented 4 years ago

Hi. So, I don't believe the problem is the multiline function declaration. We have tests that prove that multiline functions work (at least in the cases we've come up with).

To get this to parse in the first place, I suspect you've had to do some custom configuration for CMock (like maybe adding UA_DEPRECATED and UA_EXPORT to the :strippables list?). Can you paste the :cmock section of your project file here?

What version of ceedling are you using?