Created the examples directory, containing components called "before" and "after"
authorWilliam Roberts <williamr@symbian.org>
Mon, 22 Mar 2010 21:41:09 +0000
changeset 0 fe474e3b08fb
child 1 fd0863fd52e5
Created the examples directory, containing components called "before" and "after" The before directory is a component which illustrates typical issues that GCC has with the Symbian source code. Compiling this component (sbs -b bld.inf -k -c armv5_udeb_gcce4_4_1) will produce multiple errors, hence the use of "-k" to keep going. The after directory is the same component with fixes applied - compiling in the after directory should produce no errors. The aim is to keep the code very closely aligned to the before component, so that they can be compared with visual diff tools such as Beyond Compare. Sometimes it's valuable to be able to compile this code with the default production compiler, (currently RVCT 2.2) so the MMP files will switch the name of the generated executable if a different compiler is used.
examples/after/bld.inf
examples/after/e32main.cpp
examples/after/example_classes.h
examples/after/exe.mmp
examples/after/source1.cpp
examples/before/bld.inf
examples/before/e32main.cpp
examples/before/example_classes.h
examples/before/exe.mmp
examples/before/source1.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/after/bld.inf	Mon Mar 22 21:41:09 2010 +0000
@@ -0,0 +1,18 @@
+// Copyright (c) 2010 Symbian Foundation Ltd.
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Symbian Foundation - Initial contribution
+// 
+// Description:
+// BLD.INF file to build the example code
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_MMPFILES
+exe.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/after/e32main.cpp	Mon Mar 22 21:41:09 2010 +0000
@@ -0,0 +1,26 @@
+// Copyright (c) 2010 Symbian Foundation Ltd.
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Symbian Foundation - Initial contribution
+// 
+// Description:
+// Entrypoint for Symbian .exe, keeps the compiler & linker happy
+
+#include <e32std.h>
+
+// helper function for other files which need to confuse the optimiser
+int unknown(void) { return 42; }
+
+extern int source1(void);		// from source1.cpp
+
+GLDEF_C TInt E32Main()
+    {
+    // Call trivial functions in other source files, to stop them being optimised away
+		return source1();
+		}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/after/example_classes.h	Mon Mar 22 21:41:09 2010 +0000
@@ -0,0 +1,25 @@
+// Copyright (c) 2010 Symbian Foundation Ltd.
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Symbian Foundation - Initial contribution
+// 
+// Description:
+// Examples of things which GCC does not like in the Symbian codebase.
+
+// Various problems with classes
+
+class TClass1
+	{
+	public:
+	TClass1(int a, int b);
+	int Average();						// Removed classname
+	
+	private:
+	int iA;
+	int iB;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/after/exe.mmp	Mon Mar 22 21:41:09 2010 +0000
@@ -0,0 +1,31 @@
+// Copyright (c) 2010 Symbian Foundation Ltd.
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Symbian Foundation - Initial contribution
+// 
+// Description:
+// MMP file to build the example EXE
+
+#ifdef ARMCC_2_2
+#define TARGETNAME	rvct22_exe.exe		// for checking the RVCT2 compilation
+#endif
+
+
+#ifndef TARGETNAME
+#define TARGETNAME  gcce_exe.exe
+#endif
+
+TARGET TARGETNAME
+TARGETTYPE EXE
+
+SOURCE e32main.cpp
+SOURCE source1.cpp
+
+SYSTEMINCLUDE /epoc32/include
+
+LIBRARY euser.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/after/source1.cpp	Mon Mar 22 21:41:09 2010 +0000
@@ -0,0 +1,41 @@
+// Copyright (c) 2010 Symbian Foundation Ltd.
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Symbian Foundation - Initial contribution
+// 
+// Description:
+// Examples of things which GCC does not like in the Symbian codebase.
+// See the corresponding file in "after" for the preferred way to do it
+
+// Over-qualified class names
+
+#include "example_classes.h"
+
+TClass1::TClass1(int a, int b)
+	: iA(a), iB(b)
+	{}
+
+int TClass1::Average()
+	{
+	return (iA+iB)/2;
+	}
+
+int helper1(int a)
+	{
+	TClass1 c(a,11);
+	return c.Average();
+	}
+
+
+//-------------------------
+// Helper function to avoid things being optimised away
+int source1(void)
+	{
+	extern int unknown(void);
+	return helper1(unknown());
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/before/bld.inf	Mon Mar 22 21:41:09 2010 +0000
@@ -0,0 +1,18 @@
+// Copyright (c) 2010 Symbian Foundation Ltd.
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Symbian Foundation - Initial contribution
+// 
+// Description:
+// BLD.INF file to build the example code
+
+PRJ_PLATFORMS
+ARMV5
+
+PRJ_MMPFILES
+exe.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/before/e32main.cpp	Mon Mar 22 21:41:09 2010 +0000
@@ -0,0 +1,26 @@
+// Copyright (c) 2010 Symbian Foundation Ltd.
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Symbian Foundation - Initial contribution
+// 
+// Description:
+// Entrypoint for Symbian .exe, keeps the compiler & linker happy
+
+#include <e32std.h>
+
+// helper function for other files which need to confuse the optimiser
+int unknown(void) { return 42; }
+
+extern int source1(void);		// from source1.cpp
+
+GLDEF_C TInt E32Main()
+    {
+    // Call trivial functions in other source files, to stop them being optimised away
+		return source1();
+		}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/before/example_classes.h	Mon Mar 22 21:41:09 2010 +0000
@@ -0,0 +1,25 @@
+// Copyright (c) 2010 Symbian Foundation Ltd.
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Symbian Foundation - Initial contribution
+// 
+// Description:
+// Examples of things which GCC does not like in the Symbian codebase.
+
+// Various problems with classes
+
+class TClass1
+	{
+	public:
+	TClass1(int a, int b);
+	int TClass1::Average();			// Error! Member function name should not be qualified
+	
+	private:
+	int iA;
+	int iB;
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/before/exe.mmp	Mon Mar 22 21:41:09 2010 +0000
@@ -0,0 +1,31 @@
+// Copyright (c) 2010 Symbian Foundation Ltd.
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Symbian Foundation - Initial contribution
+// 
+// Description:
+// MMP file to build the example EXE
+
+#ifdef ARMCC_2_2
+#define TARGETNAME	rvct22_exe.exe		// for checking the RVCT2 compilation
+#endif
+
+
+#ifndef TARGETNAME
+#define TARGETNAME  gcce_exe.exe
+#endif
+
+TARGET TARGETNAME
+TARGETTYPE EXE
+
+SOURCE e32main.cpp
+SOURCE source1.cpp
+
+SYSTEMINCLUDE /epoc32/include
+
+LIBRARY euser.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/before/source1.cpp	Mon Mar 22 21:41:09 2010 +0000
@@ -0,0 +1,41 @@
+// Copyright (c) 2010 Symbian Foundation Ltd.
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the License "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Symbian Foundation - Initial contribution
+// 
+// Description:
+// Examples of things which GCC does not like in the Symbian codebase.
+// See the corresponding file in "after" for the preferred way to do it
+
+// Over-qualified class names
+
+#include "example_classes.h"
+
+TClass1::TClass1(int a, int b)
+	: iA(a), iB(b)
+	{}
+
+int TClass1::Average()
+	{
+	return (iA+iB)/2;
+	}
+
+int helper1(int a)
+	{
+	TClass1 c(a,11);
+	return c.Average();
+	}
+
+
+//-------------------------
+// Helper function to avoid things being optimised away
+int source1(void)
+	{
+	extern int unknown(void);
+	return helper1(unknown());
+	}