473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

playing with namespaces...

Hi,

I have a set of functions that I enclousured into a namespace due to
some conflicts.

// XYZ.h
//------
namespace CC
{
void foo();
double dfoo=0;
}

// XYZ.cpp
//--------
namespace CC
{
void foo() {dfoo=1;}
}

using namepsace CC;
int APIENTRY WinMAIN(..)
{
dfoo = 2;
foo();
}

without the namespace everything was OK, but now my GCC says:

...\lib/libc.a(winmain.o)(.text+0x14): undefined reference to `main'

Can you help?
--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}

________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com
Jul 22 '05 #1
11 1180

"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2n************@uni-berlin.de...
Hi,
using namepsace CC;


See the spelling of namespace.

-Sharad

Jul 22 '05 #2
> > using namepsace CC;

See the spelling of namespace.

Yes, sure - but that wasn't it. I just typed it here quickly for demo
purposes...
Jul 22 '05 #3

"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2n************@uni-berlin.de...
using namepsace CC;


See the spelling of namespace.

Yes, sure - but that wasn't it. I just typed it here quickly for demo
purposes...


Then your problem lies somewhere else. This compiles fine for me on g++
3.3.1.

namespace CC
{
void foo();
double dfoo=0;
}

namespace CC
{
void foo() {dfoo=1;}
}

using namespace CC;
int main()
{
dfoo = 2;
foo();
}
Jul 22 '05 #4
Gernot Frisch wrote:

Hi,

I have a set of functions that I enclousured into a namespace due to
some conflicts.

// XYZ.h
//------
namespace CC
{
void foo();
double dfoo=0;
}

// XYZ.cpp
//--------
namespace CC
{
void foo() {dfoo=1;}
}

using namepsace CC;
int APIENTRY WinMAIN(..)
{
dfoo = 2;
foo();
}

without the namespace everything was OK, but now my GCC says:

..\lib/libc.a(winmain.o)(.text+0x14): undefined reference to `main'


the linker is searching for a function

int main()
{
}

You have a function

int APIENTRY WinMAIN(..)
{
}

Does this ring a bell?

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #5

"Karl Heinz Buchegger" <kb******@gascad.at> schrieb im Newsbeitrag
news:41***************@gascad.at...
Gernot Frisch wrote:

Hi,

I have a set of functions that I enclousured into a namespace due to some conflicts.

// XYZ.h
//------
namespace CC
{
void foo();
double dfoo=0;
}

// XYZ.cpp
//--------
namespace CC
{
void foo() {dfoo=1;}
}

using namepsace CC;
int APIENTRY WinMAIN(..)
{
dfoo = 2;
foo();
}

without the namespace everything was OK, but now my GCC says:

..\lib/libc.a(winmain.o)(.text+0x14): undefined reference to
`main'
the linker is searching for a function

int main()
{
}

You have a function

int APIENTRY WinMAIN(..)
{
}

Does this ring a bell?


Just another typo. As I mentioned: Without the "namespace CC" thingy,
everything works correctly...

Really strange, huh?
-Gernot
Jul 22 '05 #6
> Just another typo. As I mentioned: Without the "namespace CC" thingy,
everything works correctly...


How about posting the full program, if possible, without any typos i.e.
copy-and-paste ;-)
Jul 22 '05 #7
Gernot Frisch wrote:

"Karl Heinz Buchegger" <kb******@gascad.at> schrieb im Newsbeitrag
news:41***************@gascad.at...
Gernot Frisch wrote:
>
> Hi,
>
> I have a set of functions that I enclousured into a namespace due to > some conflicts.
>
> // XYZ.h
> //------
> namespace CC
> {
> void foo();
> double dfoo=0;
> }
>
> // XYZ.cpp
> //--------
> namespace CC
> {
> void foo() {dfoo=1;}
> }
>
> using namepsace CC;
> int APIENTRY WinMAIN(..)
> {
> dfoo = 2;
> foo();
> }
>
> without the namespace everything was OK, but now my GCC says:
>
> ..\lib/libc.a(winmain.o)(.text+0x14): undefined reference to

`main'

the linker is searching for a function

int main()
{
}

You have a function

int APIENTRY WinMAIN(..)
{
}

Does this ring a bell?


Just another typo. As I mentioned: Without the "namespace CC" thingy,
everything works correctly...

Really strange, huh?


Could you please provide code that you tested so it doesn't contain any
of those typos. It's hard to look for errors in your original code if
you present instead code that has lots of other errors.
So make a short version of your program that you actually compiled and
that produced the specified error.

Jul 22 '05 #8
// a.h
#include "windows.h"
namespace __GLBASIC__
{
void MainGame(void);
}

// a.cpp
#include "gpc_temp.h"
namespace __GLBASIC__
{

void __MainGameSub_(void)
{ }

}

using namespace __GLBASIC__;

// Entry Point
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR
lpCmdLine, int nCmdShow)
{
__MainGameSub_();
return 0;
}

Gives this error.
Jul 22 '05 #9
Gernot Frisch wrote:

// a.h
#include "windows.h"
namespace __GLBASIC__
{
void MainGame(void);
}

// a.cpp
#include "gpc_temp.h"
namespace __GLBASIC__
{

void __MainGameSub_(void)
{ }

}

using namespace __GLBASIC__;

// Entry Point
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR
lpCmdLine, int nCmdShow)
{
__MainGameSub_();
return 0;
}

Gives this error.


And one more time. The linker searches for an entry point
of

int main()

in your program.

WinMain() is something that only a Windows compiler and Windows
linker understands. Microsoft put some standard code into
main(), which eg. gets the values for the Instance handles etc.
and then calls WinMain(). So in this environment, there is a main()
function, it comes from a library provided by Microsoft which does
initial startup initialization and then calls WinMain() as a replacement
for a user written main().

If you port such a thing to a differnt compiler on a different system,
it is *you* who has to provide a main() function as you then have
left the world of Microsoft.
--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #10
> WinMain() is something that only a Windows compiler and Windows
linker understands. Microsoft put some standard code into
main(), which eg. gets the values for the Instance handles etc.
and then calls WinMain(). So in this environment, there is a main()
function, it comes from a library provided by Microsoft which does
initial startup initialization and then calls WinMain() as a replacement for a user written main().

If you port such a thing to a differnt compiler on a different system, it is *you* who has to provide a main() function as you then have
left the world of Microsoft.


Sure, I know that - but ... wait ... Oh no!!! Now it gives me the
error even _if_ I exclude the namespace thingy... But it compiled
before!?
What .a am I missing? It used to work until yesturday... And all I did
was introducing namespaces.
-Gernot
Jul 22 '05 #11
It was a wrong definition of TCHAR for the WinMain function - sorry I
have bothered you, thank you for your help.
-Gernot
Jul 22 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Steven Bethard | last post by:
In the "empty classes as c structs?" thread, we've been talking in some detail about my proposed "generic objects" PEP. Based on a number of suggestions, I'm thinking more and more that instead of...
24
by: Marcin Vorbrodt | last post by:
Here is an example of my code: //Header file #include <vector> using std::vector; namespace Revelation { // class definitions, etc... // class members are of type std::vector }
2
by: Mike Morse | last post by:
What see sample that show xs:element where the xs namespace = http://www.w3.org/2001/XMLSchema However, I see another example with xsi: where xsi = http://www.w3.org/2001/XMLSchema-instance ...
3
by: Jim Heavey | last post by:
Trying to get the hang of Namespaces. I have primarly developed in VB and am transitioning to C# and the .Net Environment. I have worked a bit with Java as well in school about a year or so ago....
17
by: clintonG | last post by:
Using 2.0 with Master Pages and a GlobalBaseClass for the content pages. I understand the easy part -- the hierarchical structure of a namespace naming convention -- but the 2.0 IDE does not...
11
by: Random | last post by:
I'm confused about the proper use and usefulness of namespaces. I beleive I understand the purpose is so the developer can put classes within namespaces to essentially organize your code. And I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.