Closed Bug 764255 Opened 12 years ago Closed 12 years ago

Fix build warning "class 'foo' was previously declared as a struct [-Wmismatched-tags]"

Categories

(Core :: General, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 780474

People

(Reporter: ehsan.akhgari, Unassigned)

References

Details

(Whiteboard: [build_warning][mentor=ehsan][lang=c++])

Currently compiling mozilla-central with clang produces a lot of these types of warnings:

../../dist/include/nsPresArena.h:16:1: warning: class 'nsArenaMemoryStats' was previously declared as a struct [-Wmismatched-tags]
class nsArenaMemoryStats;
^
../../dist/include/nsArenaMemoryStats.h:10:8: note: previous use is here
struct nsArenaMemoryStats {
       ^
../../dist/include/nsPresArena.h:16:1: note: did you mean struct here?
class nsArenaMemoryStats;
^~~~~
struct

Fixing them is very simple, you basically need to do what clang tells you.  For example, in the above case, you should edit nsPresArena.h, and on line 61, change class to struct.

To fix this bug, all you need to do is to do a full rebuild of mozilla-central using clang (see <http://ehsanakhgari.org/blog/2011-10-18/why-you-should-switch-clang-today-and-how> for instructions on how to do this), search the build log for these types of warnings (searching for "-Wmismatched-tags" is a good idea), and fix each one.
Hi Ehsan, I'd like to work on this bug. I figure this will be a simple starting point as any for my first bug.
Assignee: nobody → isaac.aggrey
Assignee: isaac.aggrey → nobody
I am embarrassed, but I didn't realize this bug required access to an OSX box (and my shenanigans between work and class to obtain one where unsuccessful). If the bug has not changed over time, I believe this is a great starting bug for someone.
(In reply to Isaac Aggrey from comment #2)
> I didn't realize this bug required access to an OSX

I don't think you need specifically need a Mac machine to do a full build with clang. You can still build clang on Windows, which i presume you to be your OS and then modify your .mozconfig file to point to the built and installed binaries.

Clang on Windows: http://clang.llvm.org/get_started.html

//.mozconfig
================
# Ensure you set this to your LLVM_HOME path
export LLVM_HOME="/path/to/your/llvm"

# Set CC/CXX based on LLVM_HOME
export CC="$LLVM_HOME/build/Release+Asserts/bin/clang"
export CXX="$LLVM_HOME/build/Release+Asserts/bin/clang++"
(In reply to Andrew Quartey [:drexler] from comment #3)
> I don't think you need specifically need a Mac machine to do a full build
> with clang.

I actually use Linux (but also have access to Windows), and successfully built Firefox with clang (followed the Simple Firefox Build page over on MDN), but I couldn't seem to reproduce the bug at the time which made me assume the bug was OSX specific. 

For example, Ehsan mentioned ../../dist/include/nsPresArena.h produced the -Wmismatched-tags warning, but the warning did not appear to be present in my build.

However, this was about 6 weeks ago and I may have overlooked something at the time; I freshly cloned mozilla-central a moment ago and now have a compile going currently, so I will update in the morning.
Bug 780474 will make this unnecessary, so I will mark this as a duplicate of that bug.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → DUPLICATE
(Also note that we still do not support building with Clang on Windows -- Bug 752004 tracks making that possible.)
You need to log in before you can comment on or make changes to this bug.