[Part] Build failure

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: [Part] Build failure

Post by jnxd »

wmayer wrote: Mon Jul 11, 2022 8:16 am When looking at the git history then in the recent days a lot of includes has been removed in dozens of files. So, in one of the commits a header is not included any more that includes <memory> where the unique_ptr is defined. So, to fix the build failure just do what you did and add the missing file to PointConstraintPyImp.cpp
Thanks for taking care of it. Do you have an idea why this might be happening under only a few circumstances (os differences, cleanup before build)?
My latest (or last) project: B-spline Construction Project.
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: [Part] Build failure

Post by wmayer »

jnxd wrote: Mon Jul 11, 2022 10:59 am Thanks for taking care of it. Do you have an idea why this might be happening under only a few circumstances (os differences, cleanup before build)?
This can depend on different compiler, different compiler versions or different library versions.

As a general rule:
If a certain type is used in the code then the header where it is declared must be included.
An exception is a header file where a forward declaration can be used instead.

IMO the attempts to reduce the number of includes to a minimum is cumbersome because:
  • it will be mainly optimized for one specific configuration (of OS, compiler version and library versions)
  • this increases the likelihood of a failure somewhere else or sometime later if OS, compiler or a library has been upgraded
  • the time it requires to achieve that you will never ever get back with a slightly faster build
Removing unneeded includes only makes sense if the code has been changed and that specific type is indeed not used any more. But in source files you won't see a big effect because the saved time is maybe in the realm of milliseconds or much less for one source file.
It makes much more sense to remove unneeded includes in header files because a header might be included over and over again by some other header or source files and if there are many unneeded includes this can considerably slow down the build process.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: [Part] Build failure

Post by jnxd »

wmayer wrote: Mon Jul 11, 2022 12:24 pm
IMO the attempts to reduce the number of includes to a minimum is cumbersome because:
...
  • the time it requires to achieve that you will never ever get back with a slightly faster build
I think this is the only part I can disagree with. Provided the time spent reducing includes is not too much, the cumulative time saved by all people who compile may be significant.
My latest (or last) project: B-spline Construction Project.
Post Reply