473,379 Members | 1,511 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,379 software developers and data experts.

Visual C++ wrong entry point

I experience a problem where starting an application compiled with
visual C++ 6 SP5 does not execute the function main(int argc, char
**argv) and exit immediately with code 1 (0x1).

Putting main as an entry point in the section Project -> settings ->
link -> output -> entry-point symbol, makes the program calling main
but my argc and argv arguments are both equal to 0.

Has anyone an idea ?
Jul 22 '05 #1
13 3189

"Laurent Schall" <sc******@yahoo.fr> wrote in message
news:a9**************************@posting.google.c om...
I experience a problem where starting an application compiled with
visual C++ 6 SP5 does not execute the function main(int argc, char
**argv) and exit immediately with code 1 (0x1).

Putting main as an entry point in the section Project -> settings ->
link -> output -> entry-point symbol, makes the program calling main
but my argc and argv arguments are both equal to 0.

Has anyone an idea ?


Maybe your program contains global objects whose constructors fail. Does
this sound plausible?

Setting the entry point under project settings sounds like a really bad
idea, you were just messing with something you didn't understand.

john
Jul 22 '05 #2
* sc******@yahoo.fr (Laurent Schall) schriebt:

I experience a problem where starting an application compiled with
visual C++ 6 SP5 does not execute the function main(int argc, char
**argv) and exit immediately with code 1 (0x1).
As John Harrison responded, perhaps your program contains global objects
whose constructors fail.

Another possibility might be that you have used that compiler's non-standard
feature where instead of 'main' a 'WinMain' or some such (there are actually
several possibilities) is executed; in that case change the project settings
or modify the compiler/linker arguments appropriately; see your documentation.

Putting main as an entry point in the section Project -> settings ->
link -> output -> entry-point symbol, makes the program calling main
but my argc and argv arguments are both equal to 0.

Has anyone an idea?


Yes, that is off-topic in this group, but in order to get you back on
track: the entry point you specify to the linker, almost regardless of
which C++ implementation, is _not_ the 'main' function, but some function
in that C++ implementation's runtime library that in turn calls 'main'.

Jul 22 '05 #3
Laurent Schall wrote:

I experience a problem where starting an application compiled with
visual C++ 6 SP5 does not execute the function main(int argc, char
**argv) and exit immediately with code 1 (0x1).

Putting main as an entry point in the section Project -> settings ->
link -> output -> entry-point symbol, makes the program calling main
but my argc and argv arguments are both equal to 0.

Has anyone an idea ?


Main is defined as:

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

I don't know if that will solve your problem or not, but it is a start.
Jul 22 '05 #4
Julie wrote:
Main is defined as:

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


Which differs to Laurents definition (char** instead of char*[]) in what
way?

Johannes
Jul 22 '05 #5
Johannes Bauer wrote:

Julie wrote:
Main is defined as:

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


Which differs to Laurents definition (char** instead of char*[]) in what
way?

Johannes


Don't ask me -- ask the standards committee or refer to the current C++
standard.

I was simply trying to point out that the OP's implementation of main wasn't
conformant to the standard. My guess is that it might be possible that when
the compiler/linker is resolving the call to main, it doesn't resolve to the
OP's implementation, and thus resulted in their reported problem ???
Jul 22 '05 #6
Julie wrote:
Johannes Bauer wrote:
Julie wrote:
Main is defined as:

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


Which differs to Laurents definition (char** instead of char*[]) in what
way?

Johannes

Don't ask me -- ask the standards committee or refer to the current C++
standard.

I was simply trying to point out that the OP's implementation of main wasn't
conformant to the standard. My guess is that it might be possible that when
the compiler/linker is resolving the call to main, it doesn't resolve to the
OP's implementation, and thus resulted in their reported problem ???


You miss the point.

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

and

int main(int argc, char ** argv)

Are totally equivalent signatures. Indistinguishable to the compiler.

HTH,
--ag

--
Artie Gold -- Austin, Texas

"Yeah. It's an urban legend. But it's a *great* urban legend!"
Jul 22 '05 #7
Artie Gold wrote:
You miss the point.

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

and

int main(int argc, char ** argv)

Are totally equivalent signatures. Indistinguishable to the compiler.


I didn't miss the point.

Where in the standard does it say that *var[] is equivalent to **var or that
they mangle the same, or that main can be implemented w/ char **?
Jul 22 '05 #8
* Julie <ju***@aol.com> schriebt:

Where in the standard does it say that *var[] is equivalent to **var or that
they mangle the same, or that main can be implemented w/ char **?


§8.3.5/3. This specifies what information is used to determine a function's
type (otherwise known as its signature), which all declarations of a given
function must agree on. First array parameters are changed to pointers. Then
cv-qualifiers such as 'const' are deleted. Then e.g. 'register' is deleted.
Then what you're left with is the function type.

And that means, if I'm not totally mistaken, that
int main( int const nArgs, char const * const * args )
is perfectly good -- actually a bit better, I'd suggest, than the example
given in the standard...

;-)

Jul 22 '05 #9

"Julie" <ju***@aol.com> wrote in message news:40***************@aol.com...
Artie Gold wrote:
You miss the point.

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

and

int main(int argc, char ** argv)

Are totally equivalent signatures. Indistinguishable to the compiler.
I didn't miss the point.


I think you did.

Where in the standard does it say that *var[] is equivalent to **var or that they mangle the same,
No 'mangling' is occurring.
or that main can be implemented w/ char **?


ISO/IEC 14882:1998(E)

[....]

8.3.5 Functions

[....]

3

[...]

The type of a function is determined using the following rules.
The type of each parameter is determined from its own decl*
specifier*seq and declarator. After determining the type of each
parameter, any parameter of type "array of T" or "function
returning T" is adjusted to be "pointer to T" or "pointer to
function returning T," respectively.

-Mike
Jul 22 '05 #10
Alf P. Steinbach wrote in news:40****************@news.individual.net:
* Julie <ju***@aol.com> schriebt:

Where in the standard does it say that *var[] is equivalent to **var
or that they mangle the same, or that main can be implemented w/ char
**?


§8.3.5/3. This specifies what information is used to determine a
function's type (otherwise known as its signature), which all
declarations of a given function must agree on. First array
parameters are changed to pointers. Then cv-qualifiers such as
'const' are deleted. Then e.g. 'register' is deleted. Then what
you're left with is the function type.

And that means, if I'm not totally mistaken, that
int main( int const nArgs, char const * const * args )
is perfectly good -- actually a bit better, I'd suggest, than the
example given in the standard...

;-)


Are you sure, I read the standard as saying the cv-qualifier modifying
the paramiter type is removed, this is:

char * const -> char *, not
char const * -> char *.

In essence char * const and char * are different cv-qualifications of
the same type, where as char const * and char * are different types.

So int main( int const, char ** const ); is as much "const" as you
can legaly add to the usual int main( int, char ** );

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #11
* Rob Williscroft <rt*@freenet.REMOVE.co.uk> schriebt:
Alf P. Steinbach wrote in news:40****************@news.individual.net:
* Julie <ju***@aol.com> schriebt:

Where in the standard does it say that *var[] is equivalent to **var
or that they mangle the same, or that main can be implemented w/ char
**?


§8.3.5/3. This specifies what information is used to determine a
function's type (otherwise known as its signature), which all
declarations of a given function must agree on. First array
parameters are changed to pointers. Then cv-qualifiers such as
'const' are deleted. Then e.g. 'register' is deleted. Then what
you're left with is the function type.

And that means, if I'm not totally mistaken, that
int main( int const nArgs, char const * const * args )
is perfectly good -- actually a bit better, I'd suggest, than the
example given in the standard...

;-)


Are you sure, I read the standard as saying the cv-qualifier modifying
the paramiter type is removed, this is:

char * const -> char *, not
char const * -> char *.

In essence char * const and char * are different cv-qualifications of
the same type, where as char const * and char * are different types.

So int main( int const, char ** const ); is as much "const" as you
can legaly add to the usual int main( int, char ** );


Your interpretation seems much more reasonable and correct, yes.

After all it's logical that a const at the outermost level doesn't affect
what you can pass as actual arguments, whereas other const's will.

But I _like_ that version of 'main', I _want_ that version of 'main'... ;-)

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #12
Julie wrote:
Where in the standard does it say that *var[] is equivalent to **var or that
they mangle the same, or that main can be implemented w/ char **?

The C standard helpfully adds a footnote for those who don't know that *
and [] are completely equivalent in function signatures:
8) Thus, int can be replaced by a typedef name defined as
int, or the type of argv can be written as char ** argv,
and so on.

Brian Rodenborn
Jul 22 '05 #13
Default User wrote:

Julie wrote:
Where in the standard does it say that *var[] is equivalent to **var or that
they mangle the same, or that main can be implemented w/ char **?


The C standard helpfully adds a footnote for those who don't know that *
and [] are completely equivalent in function signatures:

8) Thus, int can be replaced by a typedef name defined as
int, or the type of argv can be written as char ** argv,
and so on.

Brian Rodenborn


I was not aware -- thanks to all that have pointed me in the right direction in
the standard.

I stand corrected, char ** argv to char * argv[] will most likely *not* solve
the OP's problem.
Jul 22 '05 #14

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

Similar topics

33
by: John Timbers | last post by:
I'd like to purchase Visual C# .Net for learning purposes only since it's a lot cheaper than Visual Studio (note that I'm a very experienced C++ developer). Can someone simply clarify the basic...
2
by: Bill | last post by:
Hi, I'm trying to install visual studio.net on my home machine (running xp home) to try and get some work done at home. But I am road blocked when I try and install the pre-requesites (as...
7
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using...
5
by: Anton Noll | last post by:
We are using Visual Studio 2003.NET (C++) for the development of our software in the fields digital signal processing and numerical acoustics. One of our programs was working correctly if we are...
6
by: Carmine | last post by:
When I issue a db2 list db directory command, most of the node names are wrong. Is this a bug in Db2 v7 or is there something that I am missing? Thanx...
140
by: Oliver Brausch | last post by:
Hello, have you ever heard about this MS-visual c compiler bug? look at the small prog: static int x=0; int bit32() { return ++x; }
7
by: Stefan Mueller | last post by:
I choose 'Entry 4' and click then on the button 'Set' to set the index to 'Entry 2'. If you press now the cursor down key 'Entry 5' instead of 'Entry 3' shows up with Mozilla Firefox. With Internet...
3
by: ILCSP | last post by:
Hello, I've been trying to unzip a file in Visual Basic .Net (03) but I'm getting an error. I do get the destination directory and I do get the first extracted file, but then it stops and I get an...
0
jwwicks
by: jwwicks | last post by:
Introduction This tutorial describes how to use Visual Studio to create a new C++ program, compile/run a program, resume work on an existing program and debug a program. It is aimed at the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.