CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

[Programming] Calling functions from optional .so

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By sbaffini
  • 1 Post By Gerry Kan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 5, 2022, 12:53
Default [Programming] Calling functions from optional .so
  #1
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 350
Rep Power: 10
Gerry Kan is on a distinguished road
Howdy Folks:

I just want to get a sense of what your opinions are ...

The project I am working on, any code with unused identifiers will fail the regression test. Normally it's a good thing, but I now have to make function calls to a third-party .so file that is not part of the project. The presence of this .so file is optional, so if it is not there, I will replace them with placeholder function calls that do nothing.

But here comes the problem. For the placeholder version of these functions, I need to introduce placeholder arguments to match the function prototypes in the .so. Since these arguments also do nothing, my code will not the pass regression test, because they are now seen as unused identifiers.

The question is, how should I go about this issue? I could just have statements like a = a in the placeholder function implementations to trick the compiler, but I am looking for something more elegant than this?

Thanks in advance, Gerry.
Gerry Kan is offline   Reply With Quote

Old   February 6, 2022, 01:08
Default
  #2
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,154
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
In my opinion this is something that should have been decided when the rule to fail the regression test was devised, despite seeing where that rule comes from (and how it could have underlooked possible non trivial scenarios).

For the same reason, however, this is also such a corner case that you can also avoid overthinking it. Self assignment seems to be weird enough to highlight the situation.

But maybe I would prefer defining some parameters, specifically dedicated to this, like NULL_INTEGER_INITIALIZATION, NULL_REAL_INITIALIZATION, etc., with all the necessary comments where they are used and defined. In particular, defining them in a dedicated module would even more help you track these pieces of code where this happens.
Gerry Kan likes this.
sbaffini is offline   Reply With Quote

Old   February 6, 2022, 06:08
Default
  #3
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 350
Rep Power: 10
Gerry Kan is on a distinguished road
Paolo:

Thanks. Looks like the self-assignment is the most reasonable solution in this case. Like you said, I am going to set up #ifdef blocks to section up the normal and placeholder sections of the code in the same module. Nothing more.

Gerry.

P.S. - Don't even get me started about some of the code maintainers' great ideas about project management. These people have obviously never worked in a production environment before in their lives, let alone seeing one. On one hand, they have a lot of disposable time to implement these "continuous improvements" on their own initiative, and on the other hand, these "continuous improvements" change your workflow and code base just enough you spend more time "continuously" adapting to their "improvements" than getting things done.
sbaffini likes this.

Last edited by Gerry Kan; February 6, 2022 at 08:41.
Gerry Kan is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to solve the boundary layer without wall functions? WhiteW OpenFOAM Running, Solving & CFD 4 January 20, 2020 04:55
[Commercial meshers] CCM+ Mesh Conversion Ingenieur OpenFOAM Meshing & Mesh Conversion 17 February 2, 2014 09:34
field functions - table crevoise STAR-CCM+ 3 March 26, 2013 09:37
Field functions and table crevoise Siemens 0 March 20, 2013 10:51
Windows Installation BugsComments on Petrbs patch brooksmoses OpenFOAM Installation 48 April 16, 2006 00:20


All times are GMT -4. The time now is 14:39.