missing-variable-declarations warning because of non-static variable "g_executable_path"

1,733 views
Skip to first unread message

flacs

unread,
Mar 2, 2015, 10:24:24 AM3/2/15
to googletes...@googlegroups.com
Hello,

We like to compile our project with lots of warnings enabled.

src/gtest.cc:373:13: warning: no previous extern declaration for non-static variable 'g_executable_path' [-Wmissing-variable-declarations]
std::string g_executable_path;
            ^

This could be fixed by making the variable static. (The line number is from an older version but the problem still exists in r707.)

Billy Donahue

unread,
Mar 2, 2015, 10:39:50 AM3/2/15
to flacs, Google C++ Testing Framework
More warnings making life difficult.

Is there an actual problem here?

Why should anyone care whether an 'extern' declaration precedes the definition?



--

---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Billy Donahue

unread,
Mar 2, 2015, 11:27:46 AM3/2/15
to til...@gmail.com, Google C++ Testing Framework
I appreciate the bug report.

I'm not sure we want g_executable_path to have internal linkage, but we probably do.

But if we wanted it to have external linkage, the 'extern' is implicit in C++ nonconst namespace-scope vars, and I feel weird adding a noiseword just to make a warning happy.

But we'll probably declare it 'static' to resolve this.



On Mon, Mar 2, 2015 at 11:23 AM, Tilka <til...@gmail.com> wrote:
The warning is misleading, you probably want to make the variable static. (And the warning is useful because reducing visibility helps the compiler.)

Sorry, I fail at reply-to-all...

Tilka

unread,
Mar 2, 2015, 11:30:59 AM3/2/15
to Billy Donahue, Google C++ Testing Framework
The warning is misleading, you probably want to make the variable static. (And the warning is useful because reducing visibility helps the compiler.)

Sorry, I fail at reply-to-all...
On Mon, Mar 2, 2015 at 4:39 PM, Billy Donahue <billyd...@google.com> wrote:

Corey Kosak

unread,
Mar 2, 2015, 11:32:21 AM3/2/15
to flacs, googletes...@googlegroups.com
Hi flacs,

I assume you're using Clang (set at a high warning level). Is that the only warning you are getting from Clang on gtest, or are there more? In a similar vein, what warnings are you getting on gmock?

If there are just a few of these warnings, I'll volunteer to fix them. (I realize I can run Clang myself but it will save me a little time if you just cut&paste the warnings you see from the latest gtest and gmock)



On Sun, Mar 1, 2015 at 6:22 AM, flacs <til...@gmail.com> wrote:

--

Tilka

unread,
Mar 2, 2015, 12:21:47 PM3/2/15
to Corey Kosak, googletes...@googlegroups.com
On Mon, Mar 2, 2015 at 5:32 PM, Corey Kosak <ko...@google.com> wrote:
Is that the only warning you are getting from Clang on gtest, or are there more? In a similar vein, what warnings are you getting on gmock?
Haven't used gmock yet, but a quick test compile shows no other warnings (using -Wall plus some more). -Weverything shows tons of warnings a few of which look worth fixing.

Zhanyong Wan (λx.x x)

unread,
Mar 2, 2015, 4:51:09 PM3/2/15
to til...@gmail.com, Corey Kosak, googletes...@googlegroups.com
Also, see the 2nd item in the gtest FAQ: https://code.google.com/p/googletest/wiki/FAQ#I'm_getting_warnings_when_compiling_Google_Test.__Would_you

You can use -isystem (assuming you are using gcc) to suppress all warnings in gtest headers (and other system headers) without suppressing warnings in your own code.

--

---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--




--
Zhanyong
Reply all
Reply to author
Forward
0 new messages