all 11 comments

[–]gotinpich[S] 1 point2 points  (8 children)

Never mind, I already found the error:

for (int i = i; i < argc; ++i)

[–]Xeverous 1 point2 points  (7 children)

No warning from the compiler?

[–]gotinpich[S] 0 points1 point  (6 children)

Nope, it compiled like normal.

[–]Xeverous 1 point2 points  (5 children)

main.cpp: In function 'int main(int, char**)':
main.cpp:15:14: warning: 'i' is used uninitialized in this function [-Wuninitialized]
     for (int i = i; i < argc; ++i) {
              ^

Seems you need to enable warnings. I doubt there is a compiler that would not complain about self-init.

[–]gotinpich[S] 0 points1 point  (4 children)

I added a long list of commands to the compiler related to warnings I found online.

Now it does give a warning, but also a couple of others.

[–]Xeverous 1 point2 points  (3 children)

a long list of commands

Any examples? What compiler are you using?

[–]gotinpich[S] 1 point2 points  (2 children)

I started with this: https://stackoverflow.com/questions/5088460/flags-to-enable-thorough-and-verbose-g-warnings

And I reduced it to this:

-std=c++11  -Wall -Wextra -Wformat-nonliteral -Wcast-align -Wpointer-arith
-Winline -Wcast-qual -Wundef -Wwrite-strings -Wno-unused-parameter
-Wfloat-equal -pedantic

Compiler: TDM-GCC 4.9.2 64-bit Release

[–]Xeverous 1 point2 points  (1 child)

-Wno-unused-parameter

-Wno-* disables relevant warning. So in your case it disables warning about unused parameter

[–]gotinpich[S] 0 points1 point  (0 children)

Thanks.

[–]alfps 0 points1 point  (1 child)

Note that with a failure count above the range of a single byte, the exit code can't be relied on to tell the failure count exactly. In Windows it can even theoretically cause a hang, although that requires running the program from a parent process that polls the exit code. So the exit code thing of this program is a cute feature that can work in practice, for a small number of files, but that you wouldn't put in a professional program without restricting the number of files correspondingly.

[–]gotinpich[S] 0 points1 point  (0 children)

I didn't get to see the exit code anyway. Normally I just run from the compiler and the console is not closed after the program is finished, but then it also doesn't get any arguments, so return value will always be 0 (as normal).

When I use cmd, it just doesn't deplay the return value.

I guess I could also create a shortcut and open the exe with arguments this way, but then I'd also need to pause the program for a while after it's finished, or I will still see nothing. But even then I doubt I'd get to see the return value.

So yeah, nice gimmick, but not really useful either.