I have a region of code in a seperate project that is wrapped in:
#IF MYNICEMONOTOUCHDEFINE
Some non-Monotouch C# code here
#ENDIF
The linker fails when we compile in DEBUG/SIMULATOR saying that that code is not found in monotouch basically.
The linker works fine and ignores that code when compiled to DEBUG|PHONE however.
Does the DEBUG/SIMULATOR build/linker not obey the #IF ? The IDE "ghosts" the code when in Debug|Phone mode, and un-ghosts when we switch to debug|simulator
Related
the Story
I use Symbols to control if a specific piece of Code should be included in the build or not - as most probably everyone working with C/C++ (and others) does. In this particular case I use two symbols, to control if the code running on the Microcontroller is in "Setup"-Mode, or in "EEPROM-Init Mode".
For Both Modes I use Symbols, the Setup Mode Symbol is "SWCONFIG_SETUP" and the EEPROM-Init Symbol is "SWCONFIG_EEPINIT".
The Symbols are defined in the Project Properties of CubeIDE:
The issue is:
both marked lines are skipped in debugging. I'd expect that I could step over/into them when I debug in single step moded, but the debugger just jumps over them, just as if they were disabled and the Symbol SWCONFIG_EEPINIT would not be defined.
I can control that e.g. the code is not executed, because i can not jump into the function with the debugger, and additionaly I can see the Files in the EEPROM were not erased, what would be the purpose of EEP_erase_files();
In the Code both sections are enabled, indicating that the Symbol is defined, otherwise that sections would be greyed out. In an other Code Section, using the #ifdef ... #else ... #endif syntax, the debugger jumps in the greyed out section, indication that it ignores the Symbol.
What I tried to resolve this:
I tried to rebuild/refresh the Index
I deleted the code and re-wrote it.
I deleted the Build Configuration and created it new
I deleted the Symbol in the Project Properties and created it new (using Copy & Paste from the code, to avoid typos)
The Question:
What the heck is going on here? Why is the IDE showing the code section as active, but the Debugger ignores it?
The strange thing is: this workflow allready did it's job!
Solved:
The issue was: i was starting the "Setup" Configuration, not the "SetupEEP" configuration, because for some reason i don't really understand, STM32CubeIDE does not automatically create a Debug configuration, when you create a Build configuration.
I had to create a new Debug Configuration, pointing to the executable in the SetupEEP directory. I just built the "SetupEEP" executable and pressed the debug button, but was not aware, that I started the Debug session with the executable from the "Setup" Build, because i had not created a Debug Configuration for "SetupEEP". This is why the code was omitted: because it was not included in the Build I was running ...
BTW: nice Pitfall, STM!
whenever I generate my code with STM32cubeMX on Iar embedded workbench V8.5
this error is still present
Fatal Error [Pe035]: #error directive: "Unknown target."
The error is unrelated to either downloading or debugging. It is a build error.
The #error is a pre-processor directive in the code. If you double-click on one of those errors it will no doubt take you to the offending code. It is not possible from the image to direct you to the exact cause (you should post the "build Log" text in its entirety, rather then an image of the "build" tab), but will no doubt be code similar to (elided):
#if defined(STM32F405xx)
#include "stm32f405xx.h"
#elif defined(STM32F415xx)
#include "stm32f415xx.h"
#elif
...
#elif defined(STM32F423xx)
#include "stm32f423xx.h"
#else
#error "Unknown Target" <<<< HERE - no target macro has been defined.
#endif
The point being that the HAL code supports multiple STM32 variants and it is necessary to set a macro identifying your target so that the appropriate part specific code will be built.
If you created your project using STM32CubeMX or from the IAR IDE, there will be some place in the configuration where you can specify your target. (in the case of CubeMX I don't think you can do much of anything until you have selected the target). Failing that there will be some place to define command-line build macros in the build configuration.
I want to do Unit Tests for a C project in Visul Studio 2017. It is a embedded project lib. I want make as few changes as possible to lib. Just compile c code in VS I have added some #ifdef WIN32. It ok for added some more.
Started with using Visual C++ Native Unit Test Project. But run in problems when wanted test private static functions from C files and inject values varibales in project.
Include my embedded project as Static Library in to VS solution. (or should use Dynamic-Link library or something else?)
Created Native Unit Test Project, and gave it the name UnitTest1.
In UnitTest1 added this line as I understand it will include the my lib that want test.
#pragma comment(lib, "../Release/Embedded.lib")
In the embedded code header file I added this Macro to create lib that I will preform the test on.
#pragma once
#ifdef EXPORT_TEST_FUNCTIONS
#define UNITTEST_Embedded_EXPORT __declspec(dllexport)
#else
#define UNITTEST_Embedded_EXPORT
#endif
inline UNITTEST_ZAP_EXPORT static bool isActiv(void);
In the embedded C file, I added this line #define EXPORT_TEST_FUNCTIONS and this function:
UNITTEST_ZAP_EXPORT static bool isActiv();
{
return false;
}
But when I build UnitTest1 get error LNK2001.
Very unsure how to proceed to make it work. Anyone who can guide me through my problem? I would like to be able to test all functions in C code. Hope it not hard understand what want get help with. I have only developed couple of years.
I hade same problem as you. You need to explain to the C++ compiler in Visual Studio a C header is coming when you include the declaration for the C function. So your UnitTest1.cpp should begins with:
extern "C" {
#include "somecode.h"
}
static_lib1.hshould contain something like:
#ifndef STATIC_LIB1_H_
#define STATIC_LIB1_H_
SWord doSomeThing();
#endif
Remove everything extra code that have added in your h and c-files for unit test it should not be needed. Best unit test is when don't do any changes to code you test on becouse of unit test need it.
I sure this should fix your problem.
I have an existing C-Project with a pre-written Makefile. I imported the whole thing as a Makefile-Project into Eclipse and it is working fine so far - meaning I can navigate through the code with eclipse and I can build it without problems.
Now I added some Compiler Symbols like NO_ASMto my makefile and updated the code at some points with the according lines of
#ifdef NO_ASM
// Code
#endif
This code is greyed out by my Code-Editor. Now I added the Symbol NO_ASM to
Properties/C/C++ General/Paths and Symbols and rebuilt the indexer - but the according code is still grey. Is there any way to solve this?
Are you sure you added it to all configurations? in all Languages?
You can Try Freshen all files option.
A temporal workaround can something like this:
#ifndef NO_ASM
#define NO_ASM
#endif
For some time I am trying to create a static CHOLMOD lib from SuiteSparse Each other library (f.ex. Umfpack) can be easiy compiled from IDE (I used Code::Blocks on Linux and Visual Studio on Windows). However when trying to compile CHOLMOD I get bunch of syntax errors like:
t_cholmod_triplet.c(21): error C2061: syntax error : identifier 'TEMPLATE'
I investigated that there are some #defines missing (like PATTERN, REAL defines) and therefore those definitions of TEMPLATE are invisible. I searched for them in files and in makefiles but found nothing. However when typing make (on Linux) library compiles just fine. What am I missing?
You can use SuiteSparse METIS for Windows package: https://github.com/jlblancoc/suitesparse-metis-for-windows
Credit: Jose Luis Blanco (Universidad de Almeria); Jerome Esnault (INRIA).
Actually the problem exists because of "templates" created in C. It requires to recompile the same code multiple times with different flags. I have written the VS NMakefile based on the original makegile and it compiled it seamlessly.