[GNC-dev] Can a module call a function from another module?

Geert Janssens geert.gnucash at kobaltwit.be
Sat Apr 18 08:29:36 EDT 2020


First off, modules are mostly on the way out. I have been working on removing most uses of 
those and plan to eliminate even more. The gnc_module code itself will remain until we have a 
better alternative.

Other than that, yes, you are allowed to include headers from other "modules". Or more 
generally from other compile units (the objects defined with add_library or add_object). There 
are other restrictions though:

1. you may have to add the proper include and library directories to the compile unit's 
CMakeLists.txt file. Without this the compiler won't find the header file (and later the library to 
link to)

2. In doing so you should be careful not to introduce circular dependencies. That is if unit A 
already depends on unit B, you can't make unit B also depend unit A.

3. reconcile-window.h is a C header file, while gnc-ofx-import.cpp is a C++ source file. You may 
have to include it inside an 'extern "C"' block.

You didn't provide any details as to what errors you got, so at this point it's hard to tell what 
exactly went wrong.

Regards,

Geert

Op zaterdag 18 april 2020 07:29:15 CEST schreef jeanl:
> Devs, I have a question to which I can't find an answer. It is possible for
> a function from a module (say import-ofx) to call a function from another
> module (declared in "reconcile-window.h" for example).
> I'm not able to include reconcile-window.h from gnc-ofx-import.cpp , I
> assume the build isn't setup to include the right headers.
> But perhaps this is by design and a module isn't supposed to be able to call
> another one. In that case, how can we make it so a function from a certain
> module is followed by a call to a function from a different module
> automatically?
> J.
> 
> 
> 
> --
> Sent from: http://gnucash.1415818.n4.nabble.com/GnuCash-Dev-f1435356.html
> _______________________________________________
> gnucash-devel mailing list
> gnucash-devel at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel




More information about the gnucash-devel mailing list