Re: /Zg question

Tech-Archive recommends: Speed Up your PC by fixing your registry



On 7/30/2007 4:46 AM, Charles Wang[MSFT] wrote:
Hi Bob,
Maybe there is something typing error in your .bat file.
I performed a test in command prompt and it worked fine:
F:\Projects\ZgTestC\ZgTestC>cl /nologo /c /Zg /DPROTO /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd test.c >c:\zgtest.txt

The output was generated in c:\zgtest.txt
====================
extern int __cdecl Sum(int a,int b);
extern void __cdecl f2(struct MyStruct *t);
extern int __cdecl main();
====================

For your question, is the plan to remove support in the compiler for .C code in general?
By now, I have not got any notification of removing the support of this field. If you have any questions regarding VC compiler for .c code, you can still have a new post in community.

There's no typo in the .bat file. When I run it from the command line (say, Tools > Visual Studio 2005 Command Prompt), it works, for me as well. Unfortunately, and counterintuitively, that's not a substitute for running it under program control.

The problem is when I run it from a Custom Rule (with an Additional Dependency of ..\$(InputName).c so it runs at the appropriate time), in which case the exact same batch file displays the prototypes in the Output Window and the *.pro file is now empty (zero length).

My guess is that VCE runs cl with standard output diverted to a file which allows it to capture the output for display in its Output Window. The one case in which this is the wrong thing to do is with /Zg. If they want to remove support for /Zg for .cpp and .cxx files, fine. Just leave it in for .c files -- I find it very useful -- and perhaps change its behavior to specify the output file explicitly (as in /Fo).

Here's my Custom Build Rule -- I would appreciate it if you would attempt to duplicate this problem so I can either rule out or correct a mistake on my part:

<CustomBuildRule
Name="Prototype Normal"
DisplayName="Prototyping Normal"
CommandLine="protonrm ..\$(InputName).c [$ProtoFile]"
Outputs="[$ProtoFile]"
AdditionalDependencies="..\$(InputName).c"
FileExtensions="*.pro"
ExecutionDescription="Prototyping ..\$(InputName).c [$ProtoFile]"
>
<Properties>
<StringProperty
Name="ProtoFile"
DisplayName="ProtoFile"
Description="Prototype Output File"
Switch="[value]"
DefaultValue="$(IntDir)\$(InputName).pro"
/>
</Properties>
</CustomBuildRule>

with the compiler defines moved into the .bat file.

Use (say) a dummy foo.c file with one line:

int main (void) {}

and create by hand an empty foo.pro file so that file can be added to the project the first time, after which you can erase that file. Other than directory structure, that should be enough to duplicate this problem.

Many thanks in advance for your time. I'm just trying to prove or disprove my sanity.
--
_________________________________________
Bob Smith -- bsmith@xxxxxxxxxxxxxxxxxxxxx

To reply to me directly, delete "despam".
.



Relevant Pages

  • Re: Running a program from a SQL job
    ... This works fine when running it either as a bat file or just in a cmd ... When I set the SQL job to execute the same bat ... >> command prompt in the background which SQL apparently doesn't do. ... >> command prompt and then execute a program from there. ...
    (microsoft.public.sqlserver.server)
  • Re: LNK4078: multiple .rdata and .data
    ... DDK and the kind of target environment that you want to build for, ... a command prompt from that part of the start menu. ... That is what you need in order to build a device driver or to get debug ... output from the DDK's compiler. ...
    (microsoft.public.development.device.drivers)
  • Re: LNK4078: multiple .rdata and .data
    ... DDK and the kind of target environment that you want to build for, and open a command prompt from that part of the start menu. ... That is what you need in order to build a device driver or to get debug output from the DDK's compiler. ...
    (microsoft.public.development.device.drivers)
  • Re: problem in modular programing
    ... int main ... If you've got the MS compiler set up to run from a command prompt, ...
    (comp.lang.c)
  • Re: My Documents directory has a "read only" flag
    ... So I didn't lose my mind 100% yet, I have changed the attribute before at a command prompt, not sure about a .bat file though as it's been awhile. ... You Cannot View or Change the Read-Only or System Attribute of Folders ... Rock ...
    (microsoft.public.windowsxp.general)