Discussion:
warning C4007: 'main' : must be '__cdecl'
(too old to reply)
Michael Thompson
2005-09-23 19:17:52 UTC
Permalink
All,
I am trying to compile an ANSI C program under Embedded C++ 3.0 and I am
getting Errors as follows:

Deleting intermediate files and output files for project 'INTRP - Win32 (WCE
x86em) Debug'.
--------------------Configuration: INTRP - Win32 (WCE x86em)
Debug--------------------
Compiling...
INTRP.C
C:\DownLoads\Intrp\INTRP.C(106) : warning C4007: 'main' : must be '__cdecl'
Linking...
corelibc.lib(pegwmain.obj) : error LNK2001: unresolved external symbol
***@16
X86EMDbg/INTRP.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

INTRP.exe - 2 error(s), 1 warning(s)
--------------------------------------------------------------------------------------------------------------------------

Program:

int main(argc, argv)
int argc;
char *argv[];
{

Does anyone know what is going wrong?
--
Michael T. Thompson
***@comcast.net
Steve Maillet (eMVP)
2005-09-23 19:50:32 UTC
Permalink
Wow, That's ancient K&R C - not really ANSI C.

try it as:
int main(int argc, char* argv[])
{
}

You should double check your application entry point setting in the linker
tab to make sure it's set to the correct library entry point for using main
instead of WinMain
--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com
Michael Thompson
2005-09-24 18:16:45 UTC
Permalink
Steve,
Thanks for the info. I changed the "subsystem:windows" to
"subsystem:console" and that got rid of the "error LNK2001: unresolved
external symbol ***@16" and I tried both of the "main" changes and I
get :

--------------------Configuration: INTRP - Win32 (WCE x86em)
Debug--------------------
Compiling...
INTRP.C
C:\DownLoads\Intrp\INTRP.C(108) : warning C4007: 'main' : must be '__cdecl'
Linking...
LINK : warning LNK4075: ignoring /WINDOWSCE:EMULATION due to
/SUBSYSTEM:WINDOWS specification
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
X86EMDbg/INTRP.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

INTRP.exe - 2 error(s), 2 warning(s)
--------------------------------------------------------------------------------------------------------------

with :
*******************

main(argc, argv)
int argc;
char *argv[];
{
}

and I get :
**************************

--------------------Configuration: INTRP - Win32 (WCE x86em)
Debug--------------------
Compiling...
INTRP.C
C:\DownLoads\Intrp\INTRP.C(106) : warning C4007: 'main' : must be '__cdecl'
Linking...
LINK : warning LNK4075: ignoring /WINDOWSCE:EMULATION due to
/SUBSYSTEM:WINDOWS specification
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
X86EMDbg/INTRP.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

INTRP.exe - 2 error(s), 2 warning(s)
------------------------------------------------------------------------------------------------------------------

with :
*********

int main(int argc, char* argv[])
{
}
***************************************************************************************************

which as you can see are both the same errors. If I change the "project
Options" to "subsystem:console" why would I get and error saying "LINK :
warning LNK4075: ignoring /WINDOWSCE:EMULATION due to /SUBSYSTEM:WINDOWS
specification"?? It may be an the wrong ".h" file or something like that. I
will keep working on it and let you know how it works out. Thanks again for
your help.
--
Michael T. Thompson
***@comcast.net



-----------------------------------------------------------------------------------------------------------------
Post by Steve Maillet (eMVP)
Wow, That's ancient K&R C - not really ANSI C.
int main(int argc, char* argv[])
{
}
You should double check your application entry point setting in the linker
tab to make sure it's set to the correct library entry point for using
main instead of WinMain
--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com
Steve Maillet (eMVP)
2005-09-24 18:23:16 UTC
Permalink
What OS are you building for? This group is for Windows CE. For Windows CE
you should not be mucking with the "subsystem" settings. eVC sets that
correctly when you create a project. (There is no such thing as "console"
sub system for Windows CE.) I said to check the ENTRY POINT setting.
--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com
unknown
2005-09-25 01:13:46 UTC
Permalink
Sounds like the old style WinCE emulators (x86em) used by HPC 1.0 and
Palm-sized PC (based on WinCE 2.11 if memory serves - precursor to Pocket
PC).

You should probably be targetting something a little more up-to-date for new
development (unless you really are targetting one of those older devices).
--
Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com
Post by Steve Maillet (eMVP)
What OS are you building for? This group is for Windows CE. For Windows CE
you should not be mucking with the "subsystem" settings. eVC sets that
correctly when you create a project. (There is no such thing as "console"
sub system for Windows CE.) I said to check the ENTRY POINT setting.
--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com
Michael Thompson
2005-09-25 15:05:29 UTC
Permalink
Michael,
Thank you for your email. You are mostly correct. My current setup is :

I have MS Embedded Visual C++ 3.0 running on Windows XP Pro.
The target system is a HP Jornada 680e Handheld Computer. (Hitachi SH3 @ 133
MHz)
The program I am trying to compile is a old C program written back in
the early 80's that I want to try and use on the HP.
I made the change to the "main" offline and loaded the program with eVC and
eVC responded by creating a "workspace".
I Compiled the code and the result was the error's below.

--------------------Configuration: INTRP - Win32 (WCE x86em)
Debug--------------------
Compiling...
INTRP.C
C:\DownLoads\Intrp\INTRP.C(108) : warning C4007: 'main' : must be '__cdecl'
Linking...
LINK : warning LNK4075: ignoring /WINDOWSCE:EMULATION due to
/SUBSYSTEM:WINDOWS specification
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
X86EMDbg/INTRP.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

INTRP.exe - 2 error(s), 2 warning(s)
--------------------------------------------------------------------------------------------------------------

with :
*******************

main(argc, argv) //Old style coding
int argc;
char *argv[];
{
}

and I get :
**************************

--------------------Configuration: INTRP - Win32 (WCE x86em)
Debug--------------------
Compiling...
INTRP.C
C:\DownLoads\Intrp\INTRP.C(106) : warning C4007: 'main' : must be '__cdecl'
Linking...
LINK : warning LNK4075: ignoring /WINDOWSCE:EMULATION due to
/SUBSYSTEM:WINDOWS specification
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
X86EMDbg/INTRP.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

INTRP.exe - 2 error(s), 2 warning(s)
------------------------------------------------------------------------------------------------------------------

with :
*********

int main(int argc, char* argv[]) //New style coding
{
}
***************************************************************************************************

As you can see both errors are almost the same. I believe that I may have
the setup
for the program incorrect. Is this project doable?
--
Michael T. Thompson
Post by unknown
Sounds like the old style WinCE emulators (x86em) used by HPC 1.0 and
Palm-sized PC (based on WinCE 2.11 if memory serves - precursor to Pocket
PC).
You should probably be targetting something a little more up-to-date for
new development (unless you really are targetting one of those older
devices).
--
Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com
Post by Steve Maillet (eMVP)
What OS are you building for? This group is for Windows CE. For Windows
CE you should not be mucking with the "subsystem" settings. eVC sets that
correctly when you create a project. (There is no such thing as "console"
sub system for Windows CE.) I said to check the ENTRY POINT setting.
--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com
Steve Maillet (eMVP)
2005-09-25 15:38:41 UTC
Permalink
Delete the workspace and create a new one, then add the files into it. Looks
like a bug in the automatic upgrade process.
--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com
Michael Thompson
2005-09-25 17:25:33 UTC
Permalink
Steve,
I tried your suggestion and made some progress. I got the following error
when I built the new system :

Deleting intermediate files and output files for project 'INTRP - Win32 (WCE
SH3) Debug'.
--------------------Configuration: INTRP - Win32 (WCE SH3)
Debug--------------------
Compiling...
INTRP.c
Linking...
LINK : error LNK2001: unresolved external symbol _MainCRTStartup
SH3Dbg/INTRP.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

INTRP.exe - 2 error(s), 0 warning(s)
Post by Steve Maillet (eMVP)
Delete the workspace and create a new one, then add the files into it.
Looks like a bug in the automatic upgrade process.
--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com
unknown
2005-09-25 18:01:02 UTC
Permalink
I think you need something with a "w' in it - maybe wMainCRTStartup. Why
don't you try one of the samples in the SDKs and take a look at their
settings?
--
Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com
Post by Michael Thompson
Steve,
I tried your suggestion and made some progress. I got the following error
Deleting intermediate files and output files for project 'INTRP - Win32
(WCE SH3) Debug'.
--------------------Configuration: INTRP - Win32 (WCE SH3)
Debug--------------------
Compiling...
INTRP.c
Linking...
LINK : error LNK2001: unresolved external symbol _MainCRTStartup
SH3Dbg/INTRP.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
INTRP.exe - 2 error(s), 0 warning(s)
Post by Steve Maillet (eMVP)
Delete the workspace and create a new one, then add the files into it.
Looks like a bug in the automatic upgrade process.
--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com
Steve McKewen
2005-09-25 22:40:57 UTC
Permalink
I did a similar upgrade recently and got an Entry Point Symbol of
WinMainCRTStartup. I had to change that in the project settings to
wWinMainCRTStartup.

HTH
Steve McKewen
Steve Maillet (eMVP)
2005-09-25 19:59:19 UTC
Permalink
let the wizard create a basic "hello" application for you. Then build it to
make sure all the settings and additional libs and headers are all set up
correctly. Once you can do that, add your code in using the main that is
there. NOTE: there is no support for main in the OS you are tergetting. (I'm
not even sure the C RUntime in that build will support wmain) you may need
to resort to WinMain.)
--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com
r***@pen_fact.com
2005-09-26 19:22:54 UTC
Permalink
On Sun, 25 Sep 2005 11:05:29 -0400, "Michael Thompson"
Post by Michael Thompson
Michael,
I have MS Embedded Visual C++ 3.0 running on Windows XP Pro.
MHz)
The program I am trying to compile is a old C program written back in
the early 80's that I want to try and use on the HP.
If you have the original executable, I suggest trying it under Pocket
DOS. That's an emulator that will run under Windows CE (various
versions of the operating system and various platforms). It mimics DOS
on an 80286. Could be a nice combination.

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com
Ulrich Eckhardt
2005-09-26 09:15:09 UTC
Permalink
Post by Michael Thompson
I am trying to compile an ANSI C program under Embedded C++ 3.0 and I am
[...]
Post by Michael Thompson
C:\DownLoads\Intrp\INTRP.C(106) : warning C4007: 'main' : must be
'__cdecl' Linking...
[...]
Post by Michael Thompson
int main(argc, argv)
int argc;
char *argv[];
{
Oh dude, K&R style function headers... this is really antique!
Seriously, you should make these proper C function headers. This might be
what confuses the compiler to output C4007.
Post by Michael Thompson
corelibc.lib(pegwmain.obj) : error LNK2001: unresolved external symbol
X86EMDbg/INTRP.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Now, this is because the default is to use WinMain() instead of main() as
entry point to programs. In the eVC4 environment you can change that by
telling the linker to use mainACRTStartup as entry point, you might want to
try the same for eVC3.

Please don't top-post, I will ignore any such messages.

Uli
Steve Maillet (eMVP)
2005-09-26 15:24:50 UTC
Permalink
"Please don't top-post, I will ignore any such messages."
Please ignore that! Others will ignore bottom posted messages.
--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com
Ulrich Eckhardt
2005-09-26 15:45:34 UTC
Permalink
Post by Steve Maillet (eMVP)
"Please don't top-post, I will ignore any such messages."
Please ignore that! Others will ignore bottom posted messages.
Unless anyone presents me with a reason to use TOFU in the Usenet or
otherwhere I refuse to foster this stupidity and respectlessnes. I know not
a single person that, when explained, still says top-posting is the way to
go, though several people who use crippled tools will complain that it is
harder to achieve with tose. Crippled tools need to be fixed though,
emitting TOFU and thus wasting other people's time because they have to
guess context is not an option. Doing so is unprofessional and in
particular for a technician (which all programmers are) that is a shame.

Steve, do you really advocate top-posting?

Uli
Chris Tacke, eMVP
2005-09-26 16:28:54 UTC
Permalink
Why is it hard to read from the bottom up? Why is it not courteous? When
you bottom post you force me to scroll to the bottom of the post, and if
I've been following the thread, I already know the background. See, there
is justification for top-posters. Typically I bottom post when inlining,
because then it only makes sense to respond after the OP's inquiry. As long
as the info is there and coherent, I don't see what the difference is.

I consider myself lazy enough to not have to scroll to respond or read
responses, smart enough to figure out what's going on if I come into a
thread in the middle, and indifferent enough to not care what other people
choose.
--
Chris Tacke
Co-founder
OpenNETCF.org
Are you using the SDF? Let's do a case study.
Email us at d c s @ o p e n n e t c f . c o m
http://www.opennetcf.org/donate
Post by Ulrich Eckhardt
Post by Steve Maillet (eMVP)
"Please don't top-post, I will ignore any such messages."
Please ignore that! Others will ignore bottom posted messages.
Unless anyone presents me with a reason to use TOFU in the Usenet or
otherwhere I refuse to foster this stupidity and respectlessnes. I know not
a single person that, when explained, still says top-posting is the way to
go, though several people who use crippled tools will complain that it is
harder to achieve with tose. Crippled tools need to be fixed though,
emitting TOFU and thus wasting other people's time because they have to
guess context is not an option. Doing so is unprofessional and in
particular for a technician (which all programmers are) that is a shame.
Steve, do you really advocate top-posting?
Uli
Steve Maillet (eMVP)
2005-09-26 17:36:36 UTC
Permalink
"Unless anyone presents me with a reason to use TOFU in the Usenet or
otherwhere I refuse to foster this stupidity and respectlessnes."

It is you who is without respect for insulting anyone who doesn't do things
the way you think is best by calling them stupid and "respectless".

"I know not a single person that, when explained, still says top-posting is
the way to go"

I still say so. It's just pointless to have to scroll/read past the message
you just read in order to read the response. News readers and servers
archive the original posts and provide them in a nice hierarchical thread.
So you can read the original, then the response (or responses) keeps things
focused.

I realize some people have preferences otherwise so I tolerate it without
comment but I won't let people chastise anyone for not following the bottom
post religion without comment.
--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com
Ulrich Eckhardt
2005-09-27 08:26:02 UTC
Permalink
Post by Steve Maillet (eMVP)
"Unless anyone presents me with a reason to use TOFU in the Usenet or
otherwhere I refuse to foster this stupidity and respectlessnes."
It is you who is without respect for insulting anyone who doesn't do
things the way you think is best by calling them stupid and "respectless".
Reading a bit, scrolling down to guess (not know!) the context from the
quoted material, scrolling back up and now possibly being able to
understand the reply.
It is not so much the scrolling down and up, but rather that sometimes it is
hard to map between a statement and the context it was made in. This leads
to misunderstandings. Not to do take this little pride in one's output is
stupid in my eyes.
Other than that, anyone that asks me to do this for them while at the same
time asking me for help is respectless.
Post by Steve Maillet (eMVP)
"I know not a single person that, when explained, still says top-posting
is the way to go"
I still say so. It's just pointless to have to scroll/read past the
message you just read in order to read the response. News readers and
servers archive the original posts and provide them in a nice hierarchical
thread. So you can read the original, then the response (or responses)
keeps things focused.
As I said, it is not so much about the scrolling but about the context and
specifying that context in a way that does not allow any misunderstandings.
Misunderstandings are much worse than than a little scrolling.
On a related note, many mailclients are either not capable of displaying
threads in a hierarchical view or sometimes even mess up the 'in-reply-to'
ID required for doing so, so in the context of mail instead of news this
fails in even worse ways.

That said, I generally ignore postings who's unreadability makes them
uninteresting. There is more than one way to make postings readable and
readability is not the only way to make them interesting to me. Maybe I
should have been more clear in the initial comment that spawned this
discussion.

Uli

r***@pen_fact.com
2005-09-26 19:22:57 UTC
Permalink
I have been in "conversations" where the topic was simple, folks
posted quickly, everyone top-posted, and the result was wonderful.

I have been in "conversations" where each note involved several
subtopics, and top-posting was a pain. Interleaved posting would have
been much better.

Pure bottom posting would be nice if the topic were simple _and_ the
time between posts is long enough so most folks need a refresh of the
previous posts. I haven't been involved in such a conversation for
years (early days of email, without newsgroups and newsreaders).

I have seen explanations of how bottom-posting could be nice. But none
has convinced me that it is worth changing to a different newsreader
or set of tools that might help me deal with it.

If you want to ignore top-postings, that is certainly your choice.


On Mon, 26 Sep 2005 17:45:34 +0200, Ulrich Eckhardt
Post by Ulrich Eckhardt
Post by Steve Maillet (eMVP)
"Please don't top-post, I will ignore any such messages."
Please ignore that! Others will ignore bottom posted messages.
Unless anyone presents me with a reason to use TOFU in the Usenet or
otherwhere I refuse to foster this stupidity and respectlessnes. I know not
a single person that, when explained, still says top-posting is the way to
go, though several people who use crippled tools will complain that it is
harder to achieve with tose. Crippled tools need to be fixed though,
emitting TOFU and thus wasting other people's time because they have to
guess context is not an option. Doing so is unprofessional and in
particular for a technician (which all programmers are) that is a shame.
Steve, do you really advocate top-posting?
Uli
-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com
JoeB
2005-09-26 15:58:02 UTC
Permalink
what is top and bottom posting?
Post by Steve Maillet (eMVP)
"Please don't top-post, I will ignore any such messages."
Please ignore that! Others will ignore bottom posted messages.
--
Steve Maillet
EmbeddedFusion
www.EmbeddedFusion.com
smaillet at EmbeddedFusion dot com
unknown
2005-09-26 16:15:41 UTC
Permalink
Post by JoeB
what is top and bottom posting?
What I'm doing here is bottom-posting (adding my response below the previous
post). If I add my reply above, that's top-posting.

Both practices are fairly common, but old school/religion says to bottom
post, and only include the part of the previous post that you are actually
replying to. Some don't include any of the original post (you have to read
the previous message to get context - which is sometimes hard when the reply
only pertains to a small part of the previous post).

I for one typically top-post and include the entire previous text (I admit
I'm lazy!). I've never been chastised for it (yet!), though.
--
Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com
r***@pen_fact.com
2005-09-26 19:22:53 UTC
Permalink
On Fri, 23 Sep 2005 15:17:52 -0400, "Michael Thompson"
Post by Michael Thompson
All,
I am trying to compile an ANSI C program under Embedded C++ 3.0 and I am
Deleting intermediate files and output files for project 'INTRP - Win32 (WCE
x86em) Debug'.
--------------------Configuration: INTRP - Win32 (WCE x86em)
Debug--------------------
Compiling...
INTRP.C
C:\DownLoads\Intrp\INTRP.C(106) : warning C4007: 'main' : must be '__cdecl'
Linking...
corelibc.lib(pegwmain.obj) : error LNK2001: unresolved external symbol
X86EMDbg/INTRP.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
INTRP.exe - 2 error(s), 1 warning(s)
--------------------------------------------------------------------------------------------------------------------------
int main(argc, argv)
int argc;
char *argv[];
I confess that I only partly followed the previous threads here. But I
suspect the real problem is that you are trying to use a version of
main with char args. Windows CE is heavily biased towards UNICODE, so
I would try:
int main( int argc, TCHAR argv[] )
(updating from K&R at the same time:-)
Post by Michael Thompson
{
Does anyone know what is going wrong?
-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com
Loading...