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

Repeated declarations cause problems #138

Closed
russel opened this issue Jun 3, 2017 · 8 comments
Closed

Repeated declarations cause problems #138

russel opened this issue Jun 3, 2017 · 8 comments
Labels

Comments

@russel
Copy link
Contributor

russel commented Jun 3, 2017

In /usr/include/libdvbv5/dvb-fe.h there are two instances of:

extern const unsigned fe_bandwidth_name[8];

in the C (and C++) header files this is not a problem (though I am going to report this as a bug). This leads to two lines:

extern __gshared const(uint)[8] fe_bandwidth_name;

in the generated by DStep dvb_fe.d. Sadly this leads to compilation errors:

generated/dvb_fe.d(782): Error: variable dvb_fe.fe_bandwidth_name conflicts with variable dvb_fe.fe_bandwidth_name at generated/dvb_fe.d(775)

Is this a bug in DStep or a bug in ldc2?

@jacob-carlborg
Copy link
Owner

in the C (and C++) header files this is not a problem.

Hmm, interesting.

Is this a bug in DStep or a bug in ldc2?

It's a bug in DStep.

@russel
Copy link
Contributor Author

russel commented Jun 3, 2017

I have emailed the the list on which the libdvbv5 people operate to try and get a fix. Even if they fix tomorrow and release, it will be ages before it gets to mainstream distributions. And given the glacial speed of progress of the Travis-CI folk it may get there by 2038.

@jacob-carlborg
Copy link
Owner

Ok, I see. But it's definitely a bug in DStep. I didn't know this was allowed in C code. Is it due to extern?

@russel
Copy link
Contributor Author

russel commented Jun 3, 2017

As far as I am aware you can any number of declarations for a symbol in C and C++ as long as they are mutually consistent. Only if a declaration disagrees with a previous declaration is it an error.

It turns out you have to be able to do this because of #include.

@jacob-carlborg
Copy link
Owner

jacob-carlborg commented Jun 3, 2017

It turns out you have to be able to do this because of #include.

Right, that makes sense.

Just after my rant of how #include works 😃.

@jacob-carlborg
Copy link
Owner

As far as I am aware you can any number of declarations for a symbol in C and C++ as long as they are mutually consistent.

Seems to only apply to functions without a body and extern variables, at least in a C source file.

@jacob-carlborg
Copy link
Owner

jacob-carlborg commented Jun 3, 2017

I'm mean, isn't that why include guards (or whatever they're called) are used?

@russel
Copy link
Contributor Author

russel commented Jun 3, 2017

Many header files may have to include forward declarations, so given the arbitrary code created by an include tree you can end up with many forward declaration is the compilation. This is very true in the libdvbv5 code, lots of forward declarations, many include files.

ciechowoj added a commit to ciechowoj/dstep that referenced this issue Jun 4, 2017
jacob-carlborg added a commit that referenced this issue Jun 4, 2017
Fix #138: Repeated declarations cause problems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants