How do I get the command line Delphi-2007 compiler to ignore or suppress a particular warning - delphi-2007

I am using Delphi 2007. I know how to get the IDE compiler to suppress/ignore particular warnings.
But how do I get the command line compiler to do this ?

You use the -W-[WARNING] option. The following example turns off W1036 ("Variable %s might not have been initialized"):
dcc32 test.dpr -W-USE_BEFORE_DEF
The only way I've found to find out the warning name to use is to create a simple console project in the IDE, add code that will produce the warning you want to identify, and then set the Project->Options-Compiler-Hints and Warnings to suppress that warning. Then build your project. Show the Messages window, go to the Output tab, Ctrl+A to Select all, Ctrl+C to copy.
Create a new console app.
program Test1;
{$APPTYPE CONSOLE}
uses
SysUtils;
begin
WriteLn('Test1');
ReadLn;
end.
Use Project->Options->Compiler`->Hints and Warnings, and turn off the warning(s) you want to suppress.
Build your test project.
In the Output tab of the Messages window, select all (Ctrl+A or using the context menu) and copy to the clipboard (Ctrl+C or via the context menu).
In a new Notepad window (or a new editor tab), paste in the contents of the clipboard. You'll find a long block of dcc32.exe command line similar (but probably much longer) than this (I've emphasized the relevant parts to notice):
Build started 02/05/2016 2:48:48 PM.
Project "E:\Code\Project1.dproj" (Make target(s)):
Target CoreCompile:
c:\rad studio\5.0\bin\dcc32.exe -DDEBUG;DEBUG -I"c:\rad studio\5.0\lib";"c:\rad studio\5.0\Imports";"C:\Users\Public\Documents\RAD Studio\5.0\Dcp";E:\Code\FastMM4;E:\madCollection\madBasic\BDS4;E:\madCollection\madDisAsm\BDS4;E:\madCollection\madExcept\BDS4;"E:\Code\Virtual Treeview\Source";E:\code\Indy10_5294\Lib\Core;E:\code\Indy10_5294\Lib\System;E:\code\Indy10_5294\Lib\Protocols;
--SNIPPED ANOTHER DOZEN LINES-- --no-config -W-USE_BEFORE_DEF Project1.dpr
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.12
So as a result of all this, we've identified USE_BEFORE_DEF as the warning name for W1036 for use with the command line compiler, as well as illustrated exactly how to supply it to the compiler.
You can, of course, disable more than one warning in order to identify them; I've just used one for simplicity, and snipped out a lot of the command-line output that is produced.

Related

How can I compile and execute C code without leaving editor in VS Code?

I want to quickly compile and execute C code, see the output, and then resume editing with just one shortcut key.
I installed the c/c++ compile run extension which compiles and executes the file and shows the output in the terminal. However, that leaves the terminal focused and I have to manually jump back to the editor.
I tried using a macro extension to string together two commands: one to compile and execute and one to jump back to the editor, but that didn't work. It just leaves me in the terminal.
UPDATE
OK, I modified the command macro to this in settings.json:
"macros": {
"execCMacro": [
"extension.CompileRun",
"workbench.action.focusFirstEditorGroup",
"workbench.action.focusFirstEditorGroup"
]
},
Note the duplicate command for putting the focus back to the first group. Probably has something to with it taking time for the terminal to get focus.
This probably isn't the best solution. Is there a command for inserting some short delay I might use? The macro uses the "macro-commandeer" extension.

Is it possible to view FASM preprocessor output?

I'm using fasm to compile a dll that uses macros shipped with fasm, i would like to see what the output is after the preprocessor stage but before the binary stage. Is there any way to see this? I would like to quickly see what is being generated to see if it's Worth getting rid of the dependency on the macro.
Fresh IDE has a feature "Unroll macro" - compile the source, position the caret on the row with the macro invocation and press Ctrl+U or select from the drop down menu "Unroll macro". The preprocessed code will be displayed on the scratch pad window.
If you want the whole preprocessed code at once - use the converting tools located in the FASM package, in the directory tools/ - you need to compile tools/%YOUR_OS%/prepsrc.asm.
But you should always remember, that the reverse side of having so powerful macro engine is that the complex macros are pretty hard to debug.
You could get it by prepsrc. You need to compile tools/%YOUR_OS%/prepsrc.asm by fasm.
fasm WIN32/PREPSRC.ASM
Next you need to get fas file. I do it by fasmw: Run -> Build symbols (for example let's call it file.fas).
Next:
prepsrc file.fas our_preprocessed_code.asm
our_preprocessed_code.asm will contain preprocessed souces.

symbol lookup error on a command

i'm trying to do some code in a keyboard driver, a 3rd party software that looks like this can run the command i'm trying to do in a plugin file that compiles alongside the daemon that the command needs to be sent to. the command looks like this.
g15_send_cmd (g15screen_fd,G15DAEMON_MKEYLEDS,mled_state);
here's the code i'm working with and trying to run the command in (it compiles as a plugin with the daemon. in the uncompiled source it's
"g15daemon/plugin/g15_plugin_uinput.c"
the file that defines the command is in
(link)
"g15daemon/libg15daemon_client/g15daemon_clinet.h"
whereas with the g15macro (3rd software) is run from outside the daemon for various reasons i don't want to (and pretty much can't) use it, one being speed of execution of commands when keys are pressed.
so the program compiles like this without error it seems. but if the code i specified above activates, the driver(daemon) crashes giving
g15daemon: symbol lookup error:
/usr/lib/g15daemon/1.9.5.3/plugins/g15plugin_uinput.so: undefined
symbol: g15_send_cmd
what did i do wrong or what am i missing here? (and i'm sorry if the code in the plugin file is ugly down by that switch command, but i didn't know how to do any better since i don't know C much at all, all i have behind me are Py and C#)
Edit: the solution was given
but i don't know how to add a linker flag, also since it links to a part of the program being compiled will it even work?
You forgot to link your plugin with g15daemon_client library. The simple way to fix it is to add -lg15daemon_client to the linker flags.

Syntastic C make checker not reporting errors

I'm writing C code and was initially using the gcc checker. Errors were reported in the C file. Lots of errors that didn't matter were being reported due to, for instance, no include directory switches on the gcc command line in the checker. Because we're using icc and it feels unwieldy to setup all of the parameters that are already setup in our makefile, I decided to switch over to using the make checker.
Upon switching to the make checker, I did not get any results. Looking at the makeprg command in make.vim, it is make -sk. I realized that our makefile was not setup to do syntax checking, so I created a new target called syntax_check that added the -fsyntax-only and -c flags. I then changed the make.vim makeprg command to make -sk clean syntax-check so that the appropriate target is run.
When I save the file I watched top in another window and saw that the build is occuring. However, I'm still getting no errors. By this, I mean I don't see the green sidebar indicating lines that did not have errors. Running :Errors does not bring up the location list.
Any ideas? And is my understanding of how to look at the generated errors in syntastic wrong (which it may very well be)?
As a side note for the question here, I've also got this question in on the Syntastic github page here.
It turns out that the errorformat was wrong for handling icc. This, of course, makes total sense.
The errorformat for icc that I've got so far is:
let errorformat = '%W%f(%l): %tarning #%n: %m,%E%f(%l): %trror: %m'
I will add more to this as I find errors that aren't covered by this format or find that I need different formatting.

Printing data without knowing the type?

I need to print some structure for debugging purposes.Since the code base is huge i am having difficulty locating the exact member I need to look into.Is there some way I could print out the entire structure? or atleast know what type of structure it is so that I can go back and look into it's definition?
Use a debugger. Most debuggers give you an option to see the contents of an entire structure whenever you hit a breakpoint. On *nix the most popular debugger is gdb, and on Windows the most popular IDE (which includes a debugger) is Visual Studio. Both the sited I linked to have free-as-in-beer download links.
In gdb, you can set a breakpoint with the break command, and once you reach the breakpoint you can print the contents of the struct with the print command. More specifically, you can compile with debugging data included (the -g flag in gcc), and then use
$ gdb debugging_executable
Some basic information about GDB gets printed here
> break main.c:100
> run
> print struct_variable
It's also worth looking into the step and continue commands.
In Visual Studio, you can set a breakpoint by double-clicking just to the left of the source line (there is a gray bar on the left side of the editor), and mouse over the variable name to inspect the contents once you reach the breakpoint.

Resources