I am writing a C program with Visual Studio 2015.
My C executable links to a .lib file, which is built separately from my executable.
The .lib file is also written in C. And it is built with:
cl.exe flags:
/nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /Od /GL- /Gy /EHs-c- /GR- /GF /Z7 /Gm- /Gw
link.exe flags:
/NOLOGO /LTCG
My executable is built with:
cl.exe flags:
/GS- /TC /W4 /Zc:wchar_t Z7 /Gm /O1 /Fd"C:\source\TEST2.pdb" /Zc:inline /fp:precise /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /Gd /MTd /Fa"x64\Debug\" /Fo"C:\source\x64\Debug\" /Fp"x64\TEST2.pch" /c /WX- /GS- /W4 /Gs32768 /D UNICODE /Od /GL- /Gy /EHs-c- /GR- /GF /Z7 /Gm- /Gw /wd4054 /wd4477 /U_DEBUG
link.exe flags:
/OUT:"C:\source\x64\Debug\TEST2.exe" /MANIFEST /NXCOMPAT /PDB:"C:\source\x64\Debug\TEST2.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X64 /INCREMENTAL:NO /PGD:"C:\source\x64\Debug\TEST2.pgd" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Debug\TEST2.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1 /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrtd.lib
When I debug through the whole application, I encountered below error for some breakpoints in the lib.
So I did some experiment.
In the .c file that has above issue, I tried to add break-point pair to the beginning curly bracket and ending bracket of all the C functions within that file.
I noticed that for some functions, the break-point pair can be hit. Like below:
But then I encountered a function where the break-point at the ending bracket cannot be hit. Like below:
And all the subsequent functions suffer from the same issue.
I checked this thread.
I tried clean rebuild, no use.
I use the /Z7 so there's no PDB files. I guess all debug info are embedded in the lib file.
I had /Od so I guess the optimization is not in my way.
Then what could be wrong?
Could any one shed some light? Thanks.








