smithlabcode / preseq

Software for predicting library complexity and genome coverage in high-throughput sequencing.
https://preseq.readthedocs.io
GNU General Public License v3.0
78 stars 16 forks source link

Using extensions specific to gcc #1

Closed andrewdavidsmith closed 9 years ago

andrewdavidsmith commented 10 years ago

I think the following appearing in headers works because versions of gcc supported them by extensions, not because it's standard C++. Current versions of gcc are warning against this:

// included in header in class definition static const double SEARCH_MAX_VAL = 100; static const double SEARCH_STEP_SIZE = 0.05;

The above should be declared in the class definition, but then defined outside, preferably in compiled code (the *.cpp).

timydaley commented 10 years ago

I don't really understand the problem. Why would we want to define them twice? That also means anytime we want to change them we have to change them twice.

On Sun, May 4, 2014 at 11:01 AM, Andrew Smith notifications@github.comwrote:

I think the following appearing in headers works because versions of gcc supported them by extensions, not because it's standard C++. Current versions of gcc are warning against this:

// included in header in class definition static const double SEARCH_MAX_VAL = 100; static const double SEARCH_STEP_SIZE = 0.05;

The above should be declared in the class definition, but then defined outside, preferably in compiled code (the *.cpp).

— Reply to this email directly or view it on GitHubhttps://github.com/smithlabcode/preseq/issues/1 .

Timothy Daley University of Southern California

pjuren commented 10 years ago

Andrew is right, that is an extension and is not standard C++. You wouldn't be defining them twice. You're declaring it in the header, and defining it (giving it a value) in the cpp file.

andrewdavidsmith commented 10 years ago

One is "declaration" and one is "definition."

Actually, what you are trying to do would end up failing on many compilers precisely because it would get defined multiple times...

In any case, with some compilers it will fail to compile, and in the future probably not even with GCC.

Andrew

On May 6, 2014, at 4:49 PM, Timothy Daley notifications@github.com wrote:

I don't really understand the problem. Why would we want to define them twice? That also means anytime we want to change them we have to change them twice.

On Sun, May 4, 2014 at 11:01 AM, Andrew Smith notifications@github.comwrote:

I think the following appearing in headers works because versions of gcc supported them by extensions, not because it's standard C++. Current versions of gcc are warning against this:

// included in header in class definition static const double SEARCH_MAX_VAL = 100; static const double SEARCH_STEP_SIZE = 0.05;

The above should be declared in the class definition, but then defined outside, preferably in compiled code (the *.cpp).

— Reply to this email directly or view it on GitHubhttps://github.com/smithlabcode/preseq/issues/1 .

Timothy Daley University of Southern California — Reply to this email directly or view it on GitHub.