Opened 10 years ago

Closed 10 years ago

#3403 closed defect (fixed)

Avoid using "time" as a macro variable

Reported by: Adrian Pop Owned by: Martin Sjölund
Priority: high Milestone: 1.9.3
Component: Code Generation Version: trunk
Keywords: Cc:

Description

As far as I can see we define time in Model_model.h

#define time data->localData[0]->timeValue

That has issues if you use things like

srand(time(NULL));

in your external code.

See for example:
https://test.openmodelica.org/hudson/job/SystemDynamics_Compilation/707/testReport/junit/SystemDynamics.IndustrialDynamics/Inventory/InventoryForresterNormalNoise/

The question is how do we deal with this? What does the spec says?

Change History (7)

comment:1 by Adrian Pop, 10 years ago

As this library did not change then it means that some of the changes from yesterday are to blame, probably some changes in the order of includes.

comment:2 by Martin Sjölund, 10 years ago

Would probably be best to avoid using a macro named "time" regardless.

comment:5 by Martin Sjölund, 10 years ago

Should be fixed in 85dbcb3.

comment:6 by Martin Sjölund, 10 years ago

Milestone: Future1.9.3
Owner: changed from Lennart Ochel to Martin Sjölund
Status: newaccepted
Summary: Defining "time" variable clashes with use of function time(...) in external codeAvoid using "time" as a macro variable

comment:7 by Martin Sjölund, 10 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.