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

Misleading header file in C extension (cmontecarlo1.h) #489

Closed
yeganer opened this issue Feb 12, 2016 · 11 comments
Closed

Misleading header file in C extension (cmontecarlo1.h) #489

yeganer opened this issue Feb 12, 2016 · 11 comments

Comments

@yeganer
Copy link
Contributor

yeganer commented Feb 12, 2016

For some reason there is a header file called cmontecarlo1.h declaring a single function ( which would produce compiler errors if the order of import in cmontecarlo.c was changed).

I think this function declaration should be moved to cmontecarlo.h and in that process I suggest to check if there are other potential errors.

I also suggest adding missing declarations from functions in cmontecarlo.c to it's header.

@wkerzendorf
Copy link
Member

sure - I would also like to know how to convert an issue to a PR. I think this issue is a good candidate.

@yeganer
Copy link
Contributor Author

yeganer commented Feb 12, 2016

I haven't found any new information but it seems this feature isn't available anymore.
See discussion here: mislav/hub@4f70dd1

When i am done with some implementation i'll create a PR. That seems the best approach.

@orbitfold
Copy link
Contributor

I'd ask whoever added it why they did it. It's easy to assume people made a
mistake but sometimes there are reasons you may not be aware of
On 12 Feb 2016 18:01, "yeganer" [email protected] wrote:

I haven't found any new information but it seems this feature isn't
available anymore.
See discussion here: mislav/hub@4f70dd1
mislav/hub@4f70dd1

When i am done with some implementation i'll create a PR. That seems the
best approach.


Reply to this email directly or view it on GitHub
#489 (comment).

@yeganer
Copy link
Contributor Author

yeganer commented Feb 12, 2016

When i noticed it I tried to think of a reason and didn't find one. I moved the declaration and deleted cmontecarlo1.h and it compiled and ran without errors.

I'm happy to hear a reason and be proven wrong.

@orbitfold
Copy link
Contributor

You should see when it was added. I think it was added as part of an effort
to improve performance around this September. By someone from mpa
On 12 Feb 2016 18:45, "yeganer" [email protected] wrote:

When i noticed it I tried to think of a reason and didn't find one. I
moved the declaration and deleted cmontecarlo1.h and it compiled and ran
without errors.

I'm happy to hear a reason and be proven wrong.


Reply to this email directly or view it on GitHub
#489 (comment).

@yeganer
Copy link
Contributor Author

yeganer commented Feb 12, 2016

It was added by @mreinecke during the performance improvements.
But i don't see a reason for that function to have it's own header.
To me it looks like an artifact from some test or something like that.

@wkerzendorf
Copy link
Member

okay @mreinecke is there a reason for cmontecarlo1.h

@orbitfold
Copy link
Contributor

I'm curious too actually

@mreineck
Copy link
Contributor

The reason for this curious construct was (if I remember correctly) that the function line_search() is defined (not only declared) in cmontecarlo.h, but it does not have the "static" attribute. As a consequence, if cmontecarlo.h is included by two different C files, the function line_search() turns up in each of the .o files compiled from these, and the linker will most likely complain about a function being defined twice.
There are different ways to avoid this:

  • declare line_search() to be "static"
  • move the definition of line_search() to montecarlo.c, but leave the declaration in montecarlo.h
  • play confusing games with the header files like I did.

I must admit that I don't remember why I went for this awkward solution. There probably was a reason, but maybe not a very good one.

@orbitfold
Copy link
Contributor

Also @yeganer we need to be sure the code compiles on both gcc and clang. In the past there were some issues with incompatibilities between the two.

@mreineck
Copy link
Contributor

I can help with compatibility problems ... just let me know if anything turns up!

yeganer added a commit to yeganer/tardis that referenced this issue Mar 30, 2016
Header files should only contain includes that are necessary for the
compiler to understand the header. Includes needed by the implementation
should be included by the corresponding source.

With this philosophy in mind the includes in all c files were
reorganized.
As part of this reorganization the header `cmontecarlo1.h` was removed
and it's declaration moved to `cmontecarlo.h`

Resolves: tardis-sn#489
ftsamis pushed a commit to ftsamis/tardis that referenced this issue Nov 12, 2016
Header files should only contain includes that are necessary for the
compiler to understand the header. Includes needed by the implementation
should be included by the corresponding source.

With this philosophy in mind the includes in all c files were
reorganized.
As part of this reorganization the header `cmontecarlo1.h` was removed
and it's declaration moved to `cmontecarlo.h`

Resolves: tardis-sn#489
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants