macros within .rc file - macros

I want to switch the GUID I use for an activex control based on if its a 32 bit control or a 64 bit. I would rather not have two .rc files to do this. However resource compiler ignores my pre-processor definitions inside BEGIN - END blocks and always defaults to the Control in the #else section. Please let me know if there is a better way to do this other than having two different resource(.rc) file.
BEGIN
#ifdef _Win64
CONTROL "",IDC_TCHART1,"{FCB4B50A-E3F1-4174-BD18-54C3B3287258}",WS_TABSTOP,0,15,445,199
#else
CONTROL "",IDC_TCHART1,"{FAB9B41C-87D6-474D-AB7E-F07D78F2422E}",WS_TABSTOP,0,15,445,199
#endif
END

I think it doesn't recognise pre-processor symbols defined in project properties for the compiler options, you would need to add this to the Resources properties too. Also, you can #include a file that contains a #define'ed symbol instead.
So as MSDN says :
To define symbols for your resource identifiers, use the #define
directive to define them in a header file. Include this header both in
the resource script and your application source code. Similarly, you
define the values for resource attributes and styles by including
Windows.h in the resource script.
RC treats files with the .c and .h extensions in a special manner. It
assumes that a file with one of these extensions does not contain
resources. If a file has the .c or .h file name extension, RC ignores
all lines in the file except the preprocessor directives. Therefore,
to include a file that contains resources in another resource script,
give the file to be included an extension other than .c or .h.
Having said that, it's highly likely that as soon as you modify this with the Visual Studio resource editor, you'll lose your changes.

I ran into the same issue. Turns out, the documentation here http://msdn.microsoft.com/en-us/library/windows/desktop/aa381033(v=vs.100).aspx is wrong.
It worked for me to use #if defined(FOO) instead of #ifdef FOO. I use Microsoft Visual Studio 2010.
I am pretty sure VS will overwrite these changes if you make changes in the Resource Editor.

In order to pass a preprocessor definition to the resource compiler you must also define it in the project settings (Config Properties -> Resources -> General).

Related

What was the .txt file which allows clangd to understand with what compile arguments a program gets compiled in?

I remember that there's a ".txt" file which allows to define link/compile-time arguments, but I've forgotten it's name.
I tried to google for answer.
The text file is called compile_flags.txt.
It's discussed at https://clangd.llvm.org/installation#compile_flagstxt.
Note that there are some shortcomings of compile_flags.txt compared to the more common way of configuring a project for use with clang-based tooling, compile_commands.json; most notably, clangd won't index your project with compile_flags.txt.

How to add files without extension in doxygen configuration file(e.g iostream library)?

In my configuration file in the INPUT tag I added one directory. Inside that iostream is there without any extension. After running the configuration file I'm not getting information related to iostream. I want to know how to add the files without extension in doxygen configuration file.
I created a small test example (contents is not that relevant for this test), file stdio:
/// the fie
void fie(void);
From the documentation (https://www.doxygen.nl/manual/config.html#cfg_extension_mapping):
EXTENSION_MAPPING
Doxygen selects the parser to use depending on the extension of the files it parses.
With this tag you can assign which parser to use for a given extension. Doxygen has a built-in mapping, but you can override or extend it using this tag. The format is ext=language, where ext is a file extension, and language is one of the parsers supported by doxygen: IDL, Java, JavaScript, Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL, Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: Fortran. In the later case the parser tries to guess whether the code is fixed or free formatted code, this is the default for Fortran type files).
For instance to make doxygen treat .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C.
Note: For files without extension you can use no_extension as a placeholder.
Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
Here we see that the possibility for no_extension and with the following setting we get the requested information:
EXTRACT_ALL=YES
INPUT = stdio
EXTENSION_MAPPING = no_extension=C++
and I do see the stdio information.
Edit
In case doesn't want to add all files one by one one hast to add * to FILE_PATTERNS.

How to ignore generated code in doxygen

So, we are using doxygen in a big project.
Some of the source code is generated during the build,
like my_generated_code_fragment.h
It is used in the source code, like this
file foo.cc
void foo()
{
#include "my_generated_code_fragment.h"
}
Now, when running doxygen from the repository under source control,
doxygen rightly complain that file my_generated_code_fragment.h is missing,
with an error like:
foo.cc:1234: warning: include file my_generated_code_fragment.h not
found, perhaps you forgot to add its directory to INCLUDE_PATH?
Problem
We don't want to perform a full build first, just to generate the missing
files, in order to generate documentation.
Note that the generated code does not contain doxygen comments anyway.
Solution considered so far
Do Nothing
Do nothing and ignore doxygen errors.
Not really satisfactory.
Generate dummy files
Generate dummy files like my_generated_code_fragment.h prior to running
doxygen.
This creates complications in the build scripts,
where "using doxygen" is now different on different projects,
because the files containing generated code differs.
Use preprocessor flags
Change the code to
void foo()
{
#ifndef IN_DOXYGEN
#include "my_generated_code_fragment.h"
#undef IN_DOXYGEN
}
and set PREDEFINED
This is the best solution considered so far, but it means changing the code.
Question
Is there a better option, like tell doxygen using a setting in Doxyfile
that file my_generated_code_fragment.h is expected to be missing,
and should be ignored ?
Note:
EXCLUDE does not work for this,
as the error is seen when parsing file foo.cc, not when parsing the generated code.
Using doxygen version 1.8.5 at the moment.
Documenting the solution taken then.
Solution 3, to use pre-processor flags when building with doxygen, and changing the (small) parts of the code that uses generated content worked well.
This allows to use doxygen on "raw" source code, pulled from git.

Doxygen / source file comments

Is any way to not generates warrnings from undocumented function/method that is located in source file ( .c ) . I have all comments in header file and do not want to duplicate it.
I do not want to switch off documenting source code but only comments for method in this file.
Thanks in advance for any suggestions.
I can think of two approaches you could take, both by changing config options in your Doxyfile:
If you set WARN_IF_UNDOCUMENTED to False (it defaults to True), doxygen won't complain about any function or method which is undocumented. (You might not want to do that though, as the warnings can be a helpful way to check you've documented all your methods and functions.)
Set your config to include or exclude files based on their suffix. For example: if the methods and functions which are causing problems all have a .c suffix, you can set EXCLUDE_PATTERNS to *.c to ignore all .c files.
The doxygen configuration documentation is pretty comprehensive, and you may find another approach in there which suits better.

eclipse doxygen excluding part of the path name

I'm using Eclipse and Doxygen on a Linux platform. My teams code is controlled with Clearcase. My question is can I use an environment variable as part of the path to excluded?
example: every one on the project has a custom view as part of their path. And I don't want to see that in the documentation.
/view/me/a/b/src/.../...
/view/you/a/b/src/.../...
in each developers view their is an environment variable defined with their view name. ex: $CLEARCASE_ROOT = /view/me
So I'm trying to setup a single Doxygen file for whole team to use..
So I want to do something like EXCLUDE ${CLEARCASE_ROOT}/a/b
Then everybody that generates docs will get the same paths.. Can I do this??
Thanks.
Yes, doxygen supports environment variable expansion in its configuration files, see http://www.doxygen.nl/manual/config.html.
The EXCLUDE option controls which files are parsed by doxygen. It sounds like you want the files to be included, but you want them to be displayed with a relative include path, in that case you probably want to use the STRIP_FROM_INC_PATH option. If there are other absolute paths in the documentation you're attempting to make relative, the STRIP_FROM_PATH option may also come into play.
The syntax is a little different than what you proposed, $() vs. ${}, so you'll want to specify something like:
STRIP_FROM_INC_PATH = $(CLEARCASE_ROOT)/a/b
STRIP_FROM_PATH = $(CLEARCASE_ROOT)