How to enable run-time type information in Catia CAA? - visual-studio-2012

While developing a plug-in for Catia using the CAA C++-Interface, I need to do a dynamic_cast:
DerivedClass *derived = dynamic_cast<*derived>(base);
When Build with mkmk, the compiler gives the warning:
[MkMk] warning C4541: 'dynamic_cast' used on polymorphic type '<DerivedClass>' with /GR-; unpredictable behavior may result
I tried to enable the run-time type information by adding LOCAL_CCFLAGS = /GR to the Imakefile.mk of the module. But the compiler overwrites this flag and disables the RTTI:
[MkMk] Command line warning D9025 : overriding '/GR' with '/GR-'
[MkMk] warning C4541: 'dynamic_cast' used on polymorphic type '<DerivedClass>' with /GR-; unpredictable behavior may result
How do I enable the RTTI correctly?

Related

Cannot disable warning in Visual C++

I need to disable all warnings from a directory of a project which uses the external library ProtocolBuffers, which produces its own warnings.
These are some of the 151 warnings I get:
my.pb.cc: warning C4512: 'google::protobuf::FatalException' : assignment operator could not be generated
my.pb.cc: warning C4244: 'initializing' : conversion from '__int64' to 'int', possible loss of data
my.pb.cc: warning C4125: decimal digit terminates octal escape sequence
my.pb.cc: warning C4127: conditional expression is constant
my.pb.cc
xutility(2132): warning C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS.
Where xutility is a Visual Studio include file.
If I add these lines in my CMakeLists.txt file:
# Use a lower warning level threshold for autogenerated files
set(PROTOBUF_FILES_PATH "${CMAKE_CURRENT_BINARY_DIR}/src/*.pb.*")
file(GLOB PROTOBUF_FILES ${PROTOBUF_FILES_PATH})
set_source_files_properties(${PROTOBUF_FILES} PROPERTIES COMPILE_FLAGS /W2)
I get all warnings from my generated pb.cc files disabled, but I still have 15 warnings left from ProtoBuf's internal code, of the type:
my.pb.cc
xutility(2132): warning C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS.
How can I disable these last warnings, possibly adjusting my CMakeLists.txt file adding the -D_SCL_SECURE_NO_WARNINGS option, just for files with extension *.pb.*, considering I cannot modify ProtoBuf itself?
Without knowing much about xutility or how it is used by Protobuf, I would suggest trying to expand your set_source_files_properties() call to include COMPILE_DEFINITIONS:
set_source_files_properties(${PROTOBUF_FILES} PROPERTIES
COMPILE_DEFINITIONS _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS /W2
)

Recordwildcards crashes at runtime in yesod app

I ran into the following error which is quite surprising. I added a field to the AppSettings in a Yesod app (using the Yesod scaffholding) and to my surprise, everything compiled even though I didn't do anything else (I was expecting to have to add somewhere a default value to the construction of AppSettings, but not). I got a runtime error instead telling me that a field was missing.
It appears that the only construction to AppSetting uses the RecordWildCards extension and looks like AppSettings{..}. Not defining the new field didn't generate an error but a warning (I didn't see it, because I was running test in continuous mode using stack test --file-watch). How is that possible ?
I try to reproduce the problem in a simple file and I get an error not a warning. So why do I get a warning for Yesod ? Is it a compilation flag or something ?
Edit
This is not specific to Yesod. I've made the test again with a simple file and it generates a warning not an error.
According to changelog in GHC, "that not a bug, it's a feature": https://ghc.haskell.org/trac/ghc/ticket/5334
You can change this behavior by changing type of your fields to strict (prepend a ! to type name - like !Int) - however, then you lose laziness (more about effects of strict types: Advantages of strict fields in data types)
Of course, you can also make it an error by slamming in -Werror compilation option, but then you need to be very strict about your code (no unused imports, no unused variables, even when unpacking a record etc.), or get rid of -Wall and turn on only warnings you perceive as important.

LINK : warning LNK4098: defaultlib 'mfc90ud.lib' conflicts with use of other libs; use /NODEFAULTLIB:library

This warning seems to be related to a runtime error I'm having. If I ignore this warning, I get an exception when using a method in a library. If I try to fix this warning using the /NODEFAULTLIB switch, I'm not able to build because of undefined symbols.
I found out the problem. There was a mismatch between the character set in the static library, and the character set in the application.
enter image description here

enumeration values not handled in switch

When compiling my project as a 64bit target (this isn't considered a warning on 32bit target) I get this warning:
5 enumeration values not handled in switch: 'kCreated', 'kLoaded', 'kConnected'...
I have somehow managed to turn off the error/warning message numbers, so I don't know what number to suppress in my code with #pragma warn.
I need to use #pragma warn because I only want to suppress approved places in my code (turning the warning off and on again).
Bonus question: Does anyone know how to get back the error/warning numbers again?
The 64bit compiler is based on CLang, which does not use warning numbers, which is why you do not see them. The following info comes from Bruneau Babet, one of C++Builder's chief developers, in the Embarcadero forums:
How do I suppress 64bit XE3 warnings?
Warnings in clang, hence bcc64, don't have the Wxxxx numbers. Behind the
scene there is a unique id generated for each warning but it's
auto-generated and cannot be assumed to remain constant across builds.
Instead each warning has a group. Related warnings are often in the same
group. Some groups have just one warning. To disable warnings of a group
you can use "-Wno-" on the command line, or via something like
the following in code:
#pragma clang diagnostic ignored "-W<groupname>".
For example, the first warning you listed is under the group "float-equal".
So, "-Wno-float-equal" should disable that warning. And to disable the one
about an enumerator not handled in the switch you can use the following in
code:
#pragma clang diagnostic ignored "-Wswitch"
So the next obvious question is how to find out about each group. The
"-fdiagnostics-show-option" should trigger the compiler to display the
option but unfortunately the IDE does not honor that option. So you must
either use the command line to find out about the group ach warning belongs
to, or you can peek at the Warning declarations here:
https://github.com/llvm/llvm-project/tree/main/clang/include/clang/Basic
The *.td files declare the various warnings. The ones mentioned above are
https://github.com/llvm/llvm-project/tree/main/clang/include/clang/Basic/DiagnosticSemaKinds.td
Oddly, #pragma clang is still not documented on the Embarcadero DocWiki.

linux/htimer: compiler error due to unknown struct size

One of the (kernel)headers I'm using, will not compile due to an error from the following line of code(I'd rather not post the whole header since you can look it up #lxr.free-electrons.com and it's only 1 line that has a bug in it).
This is the problem(it uses a preprocessor macro):
DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
The gcc compiler error is as follows:
error: storage size of ‘per_cpu__tick_cpu_device’ isn’t known
So the tick_device struct is defined but what seems to be the trouble here?

Resources