Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SofaKernel] Header include cleanup #638

Merged
merged 30 commits into from
May 31, 2018

Conversation

epernod
Copy link
Contributor

@epernod epernod commented Apr 16, 2018

Just removing unnecessary headers include inside header in sofa::core
No forward class or intelligent refactoring.

any suggestion/remark is welcomed.


This PR:

  • builds with SUCCESS for all platforms on the CI.
  • does not generate new warnings.
  • does not generate new unit test failures.
  • does not generate new scene test failures.
  • does not break API compatibility.
  • is more than 1 week old (or has fast-merge label).

Reviewers will merge only if all these checks are true.

@epernod epernod added the pr: status wip Development in the pull-request is still in progress label Apr 16, 2018
@epernod epernod changed the title Header include cleanup [SofaKernel] Header include cleanup Apr 17, 2018
@epernod epernod self-assigned this Apr 18, 2018
@hugtalbot hugtalbot added the pr: clean Cleaning the code label Apr 24, 2018
@epernod epernod added this to the v18.06 milestone May 9, 2018
…er headers. Remove GeneralLoader.h and GeneralLoader.cpp which are not anymore used.
@damienmarchal
Copy link
Contributor

[ci-build][with-scene-tests]

@@ -21,11 +21,8 @@
******************************************************************************/
#ifndef SOFA_COMPONENT_LOADER_SPHERELOADER_H
#define SOFA_COMPONENT_LOADER_SPHERELOADER_H
#include "config.h"
Copy link
Contributor

@damienmarchal damienmarchal May 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about removing this one....because no one will define SOFA_TARGET anymore.

While it is supposed to be used in the ObjectFactory:

/// The name of the library or executable containing the binary code for this component
    virtual const char* getTarget()
    {
#ifdef SOFA_TARGET
        return sofa_tostring(SOFA_TARGET);
#else
        return "";
#endif
    }

EDIT: Actually all the component in SofaGeneralLoader should have somewhere the target set to SOFA_TARGET "SofaGeneralLoader" (which I'm sure is what is happening).

NB: I'm really not found of silently ignoring the undefined SOFA_TARGET.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I can revert that. I think it has been removed because this class include already another loader header that include config.h
If the logic is: every class include it's config.h, I'm ok with it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should replace this code by:

#ifndef SOFA_TARGET
        #error....the SOFA_TARGET is not defined. 
#else: 
        return sofa_tostring(SOFA_TARGET);
#endif 

(Not in this PR of course)

Copy link
Contributor Author

@epernod epernod May 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will put those headers back and we will see later where those target should be set.

@@ -1,33 +0,0 @@
/******************************************************************************
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Erik,

I'm not sure this one should be removed, on the contrary its use should be generalized. Additionally I think it should also define the SOFA_TARGET to SofaGeneralLoader.

Please confirm @guparan

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I sent a message to @guparan already regarding this.
Right now all macros are defined in sofa-build\include\SofaMisc\config.h etc..
This class is not included. Let me know which one should be kept. I'll revert the commit if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will report our discussion in an issue and remove that change from the PR to have only changes on header includes.

@@ -1,35 +0,0 @@
/******************************************************************************
Copy link
Contributor

@damienmarchal damienmarchal May 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you removed also code ?

From PR description I would have expected only changing lines with #include

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I saw all includes could be removed because this class is not anymore in the cmakeLists.
Another PR regarding deprecated files will be better indeed because I found other similar cases.

@epernod
Copy link
Contributor Author

epernod commented May 28, 2018

[ci-build][with-scene-tests]

@epernod epernod added pr: status to review To notify reviewers to review this pull-request and removed pr: status wip Development in the pull-request is still in progress labels May 28, 2018
@hugtalbot hugtalbot added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels May 30, 2018
@damienmarchal damienmarchal merged commit e959abb into sofa-framework:master May 31, 2018
@damienmarchal
Copy link
Contributor

READY and recently compiled over the issofa PR ...I merge it.

@epernod epernod deleted the header_include_cleanup branch May 31, 2018 07:53
@@ -22,17 +22,14 @@
#ifndef SOFA_CORE_BEHAVIOR_BASEMECHANICALSTATE_H
#define SOFA_CORE_BEHAVIOR_BASEMECHANICALSTATE_H

#include <sofa/config/build_option_experimental_features.h>
Copy link
Contributor

@damienmarchal damienmarchal May 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged without noticing this one.
It shouldnt be removed.
Because this one add some macro that are tested with
#ifdef XXXXX

So removing it "compile" but the resulting code is not working anymore.
....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A very bad things is that even in condition like #if MACRO == 1
When the macro is not defined then its value is == 0 so removing the include line is silent.
https://gcc.gnu.org/onlinedocs/cpp/If.html

A workaround I can propose it to do:

#define MYTEST() 0 
....
#if MYTEST() 
        std::cout << "COUCOU A" << std::endl ;
#else
        std::cout << "COUCOU B" << std::endl ;
#endif 

So that we get error when MYTEST is not defined (the bad things is that the error is not very clear with some compilers):
with gcc:
toto.cpp:8:11: error: missing binary operator before token "("
#if MYTEST()

with clang:
toto.cpp:8:5: error: function-like macro 'MYTEST' is not defined
#if MYTEST()
^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: clean Cleaning the code pr: status ready Approved a pull-request, ready to be squashed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants