欢迎使用CSDN-markdown编辑器
When i download the newset version of TRDP source code from TCNopen web. it can pass build at VS2010 compiler environment. but when run as step by step it always report out init socket function with error. deep debug in the issue. i found the issue comes from the parameters of main function, input buffer [int main(int argc, char * argv[])][6] argv[],the imput paramenter do not right. for example it transmit the local ip address as 10.0.0.220. but after check the ipconfig under cmd command windows non any ip address setting as those ip. so it may the roon reason why socket init failure.
[Organize thoughts][6]
- Check main function call by which file
- Sreach configuration file in project
- What system do before main function call
- *crtexe.c*files
Step 1 main function call
- main function call by crtexe.c in function
__declspec(noinline)int __tmainCRTStartup( void)
#ifdef WPRFLAG
__winitenv = envp;
mainret = wmain(argc, argv, envp);
#else /* WPRFLAG */
__initenv = envp;
mainret = main(argc, argv, envp);
#endif /* WPRFLAG */
- Obviously system do some operation at
_setargv()
- So question is comming what does VS do before the main funciton call at file
crtexe.c
Step 2 crtexe.c file analysis
This is a C file, in VC, crtexe.c provides c / c ++ main caller: wWinMainCRTStartup / WinMainCRTStartup / wmainCRTStartup / mainCRTStartup implementation. Crtexe.c file is used to generate C Run Time dynamic link library, that is, if the project uses the C Run Time dynamic link library compiler form, then compile the program entry point is used crtexe.c code
So this file just a system call seems we do not need care about what it is, but where does the parameter transmit still unknow.
get a pointer to the complete command line of the new process;
to obtain a pointer to the new process of the environment variable;
Initialize the global variables of the C / C ++ runtime
Initialize the constructor for all global and static C ++ class objects.
For a program, the mainCRTStartup or wmainCRTStartup function in the crtexe.c file is executed >before the main function is executed
step 3 where the local ip address setting from?
Search whole project and docuemtns non files or setting define those ip address as 10.0.0.220
So, it may do not read it from file or system.
Step 4 Main function parameter passing
Redirect input or Peline there are some place send the input to main.
[“http://www.opencv.org.cn/index.php/Main%E5%87%BD%E6%95%B0%E5%8F%82%E6%95%B0argc%EF%BC%8Cargv%E8%AF%B4%E6%98%8E“][1].
- Do sample test1
- run [Win32TRDP_PDTest.exe][6] under cmd windows
- it will alarm there is not enough parameters.
So it clean there must be some place input the paramenter to target execulte file.
Step 5 check whether VS2010 has those interface or not
- indeed at VS2010
-
project >- property >-Configure properties -> debugging >-Command parameter
192.168.1.97 192.168.1.20 239.193.0.0 test.txt
printf("usage: %s <localip> <remoteip> <mcast> <logfile> ", argv[0]); printf(" <localip> .. own IP address (ie. 10.2.24.1) "); printf(" <remoteip> .. remote peer IP address (ie. 10.2.24.2) "); printf(" <mcast> .. multicast group address (ie. 239.2.24.1) "); printf(" <logfile> .. file name for logging (ie. test.txt) ");
- 上一篇: js中数组的复制
- 下一篇: 解析各大电子商务网站订单号的生成方式