Nothing that I can see. I just did a build with -Wl,-Map,output.map and it worked fine. But the error message you have suggests that the linker is trying to read -Wl,-Map,output.map as a script file for some reason. I am not sure whether the MCU g++ linker is significantly different from the standard ld linker, but you may want to check the documentation.
It's probably a stupid question, but is there any way to make anonymous function usage like that compile inside a file with .c (not .cpp) extension? I know I'm allowed to put snippets of C-code inside a C++ file, but I suppose the opposite isn't possible (not even with clever macros)?
You have two choices:
1. Your program needs specific argument values which you must check by iterating over the items in argv. The actual number and type is for you to decide.
2. Your program does not accept command line arguments in which case you just ignore them. You may wish to display a warning message if argc is greater than 1.
You did not mention what error you received, but I assume it is because you are still trying to access an item which does not exist. The values for argc and argv are as follows:
1. argv is an array of strings, which will always contain at least one item: the name of the executable that is used to initiate the program.
2. argc contains the number of items in the argv array. So it will always be at least 1.
Let's look at a couple of examples:
1. A simple command line call to run my program, which is called Test.exe produces the following:
If we add some parameters to the command line we will get something like
C:\Users\user1\Documents\Code\C++>Test.exe one two "three and a half"
argc = 4
argv = Test.exe
argv = one
argv = two
argv = three and a half
So argv now contains 4 items, the program name followed by each item that is separated by a space or tab. Not that argv contains four words, since they were delineated by double quotes in the command line.
The code to list these values is as follows:
std::cout<<"argc = "<< argc <<std::endl;
for (int i = 0; i < argc; ++i)
std::cout<<"argv["<< i <<"] = "<< argv[i] <<std::endl;
Generally you are not interested in the program name so you can start the above loop from 1 rather than 0.
The actual values in each parameter are for you to decide. You can use simple strings in a specific or random order, option letters or names preceded by single or double dashes or forward slashes:
Test check \foo\bar\filename.txt
Test -c C:\user1\Documents\file.jpg
Test --check somefilename
The simplest way to do this is to read the file line by line and check for the data that you are interested in. Remember a text file is just a stream of characters with no structure so you cannot easily use file positioning to get to a particular item.