infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

Dave

+ Reply to Thread
Results 1 to 6 of 6

Thread: Conditional compile over Build-Configurations

  1. #1
    Beginner Beginner xmcuser17 is on a distinguished road
    Join Date
    Aug 2016
    Posts
    12
    Points
    95

    XMC_AssertHandle and Conditional compile over Build-Configurations

    Hi.

    Is there a way to compile a project conditional?

    I set up a new Build Configuration : TEST.
    Only in this configuration, i want to compile the Uart modules to serve the XMC_ASSERT() to a uart output.

    To implement this solution, i add a new Build Variables "TEST_ACTIVE" Type:String Val:"0" to the TEST configuration.
    ( -> Properties for My Project, -> C/C++ Build -> Build Variables; Configuration: TEST )

    Click image for larger version

Name:	Unbenannt.jpg
Views:	0
Size:	37.5 KB
ID:	2767
    In the source code i place a : #ifdef TEST_ACTIVE (Code between) #endif

    I set Configuration TEST active, but the compiler doesn't know the Variable "TEST_ACTIVE".

    How can i solve this, or isn't it possible to set up a Configuration for this?

    And how to implement and activate the XMC_AssertHandler?

    If i define a XMC_AssertHandler() over Uart, the problem will be: during init from the Uart, XMC_AssertHandler is called, but uart is not working at this time.
    Then the cat bites into the tail.
    What is there before: the egg or the chicken?

    And how can i enable XMC_AssertHandler() for my user-output?
    I define XMC_ASSERT_ENABLE in xmc_common.h, but this doesn't work.....

    My Handler looks like this:

    Code:
    void XMC_AssertHandler(const char *const msg, const char *const file, uint32_t line)
    {
    	uint8_t cBuffer[256];
    	uint16_t iLen=0;
    
    	iLen = sprintf( cBuffer, "%s %s %d",msg, file, line );
    	UART_Transmit(&UART_1 , cBuffer,  iLen );
    }
    Last edited by xmcuser17; Feb 3rd, 2017 at 06:05 AM.

  2. #2
    Beginner Beginner xmcuser17 is on a distinguished road
    Join Date
    Aug 2016
    Posts
    12
    Points
    95

    No conditional compile ?

    Hi.

    I've test the same with Symbols, without any success.
    I add a symbols for the compiler and the same for the assembler ( UNIT_TEST ):

    A #ifdef UNIT_TEST block, won't be compiled!!!

    Click image for larger version

Name:	Unbenannt2.jpg
Views:	0
Size:	65.2 KB
ID:	2770

    Any idea to compile conditional????????

  3. #3
    Beginner Beginner xmcuser17 is on a distinguished road
    Join Date
    Aug 2016
    Posts
    12
    Points
    95
    Hi.

    Is really no one here who has ever tried conditional compile with dave?
    Has no one any idea to set up a "Conditional compile" with dave?

    How do you do unit tests ? ????
    Do the test functions always remain active and only a test is executed instead of a program run in your project (because no conditional compile possible??) ???

    ?

  4. #4
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    jferreira will become famous soon enough
    Join Date
    Oct 2012
    Posts
    172
    Points
    3103.1640625
    Hi,

    You are looking for setting preprocessor symbols.
    Go to the Properties of your project and click on C/C++ Build>Settings>ARM-GCC C Compiler>Preprocessor.
    Click image for larger version

Name:	preprocessor_symbols.png
Views:	1
Size:	47.1 KB
ID:	2774

    On how to use the XMC_ASSERT have a look to the attached example included in XMClib examples/XMC4500_series/UART/UART_PRINTF
    Click image for larger version

Name:	XMCLIB_ASSERT.png
Views:	0
Size:	7.8 KB
ID:	2775

    Regards,
    Jesus
    ?????
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  5. #5
    Beginner Beginner xmcuser17 is on a distinguished road
    Join Date
    Aug 2016
    Posts
    12
    Points
    95
    Hi jferreira.

    Thanks for you reply.

    But this is NOT working in combination with a additional Build-Configuration.

    Let me explain.

    I have 3 build-configurations:
    - Debug
    - Release
    - Test (for unit-test's)

    If i work in Debug-configuration and add a preprocessor-symbol "UNIT_TEST" ( in Properties of my project C/C++ Build>Settings>ARM-GCC C Compiler>Preprocessor)

    the compiler knows the symbol if defined -> . #if defined(UNIT_TEST) is working


    If i work in Release-configuration and add a preprocessor-symbol "UNIT_TEST" ( in Properties of my project C/C++ Build>Settings>ARM-GCC C Compiler>Preprocessor)

    the compiler knows the symbol if defined -> . #if defined(UNIT_TEST) is working


    But, if i add a preprocessor-symbol "UNIT_TEST" only in Build-configuration Test ( and delete the symbol in config Debug and Release)
    the compiler doesn't know the define: #if defined(UNIT_TEST) is not working

    I set configuration Debug as active -> symbol UNIT_TEST unknown -> correct
    I set configuration Release as active -> symbol UNIT_TEST unknown -> correct
    I set configuration Test as active -> symbol UNIT_TEST unknown -> bug / failure !!! The code-block is greyed out -> see picture below

    I used BuildConfiguration -> Set Active -> Test
    and i used BuildConfiguration -> Manage: choose Test and -> Set Active
    to switch between the 3 Build-Configurations.


    Is this a Bug in Dave?

    Click image for larger version

Name:	Active1.png
Views:	0
Size:	14.3 KB
ID:	2780

    Click image for larger version

Name:	Active2.png
Views:	0
Size:	27.7 KB
ID:	2781



    The code-block is greyed out:

    Click image for larger version

Name:	Active3.png
Views:	0
Size:	19.1 KB
ID:	2782
    Last edited by xmcuser17; Feb 16th, 2017 at 04:41 AM.

  6. #6
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    jferreira will become famous soon enough
    Join Date
    Oct 2012
    Posts
    172
    Points
    3103.1640625
    Hi,

    For me it is working. I created a third configuration, named Test, as a copy of the Debug one.
    In the properties of the project, in the preprocessor macros I added UNIT_TEST.

    For the Debug and Release configurations, the macro is not defined and therefore the code is grayed out.
    Click image for larger version

Name:	indexer_debug.png
Views:	0
Size:	36.8 KB
ID:	2787

    For the Test configuration the macro is defined and therefore the code is not grayed out.
    Click image for larger version

Name:	test_indexer.png
Views:	0
Size:	35.7 KB
ID:	2788

    Please check the setting in the indexer
    Click image for larger version

Name:	dave4_indexer.png
Views:	2
Size:	25.8 KB
ID:	2786

    Sometime also helps to rebuild the index.

    Regards,
    Jesus
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

+ Reply to Thread
Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.