This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

badly formed pragma

Other Parts Discussed in Thread: MATHLIB

I'm migrating from DSP/BIOS to SYS/BIOS (CCSv5.2.2, BIOS 6.33.05.46, XDC Tools  3.23.03.53). I have successfully run the ti.bios.conversion utility which generated a cfg file and RTSC platform package. When I build my project, I get several of the following errors regarding the math library:

Description    Resource    Path    Location    Type
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\atan2sp\c674\atan2sp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\atandp\c674\atandp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\atansp\c674\atansp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\cosdp\c674\cosdp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\cossp\c674\cossp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\divdp\c674\divdp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\divsp\c674\divsp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\exp10dp\c674\exp10dp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\exp10sp\c674\exp10sp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\exp2dp\c674\exp2dp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\exp2sp\c674\exp2sp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\expdp\c674\expdp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\expsp\c674\expsp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\log10dp\c674\log10dp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\log10sp\c674\log10sp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\log2dp\c674\log2dp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\log2sp\c674\log2sp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\logdp\c674\logdp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\logsp\c674\logsp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\powdp\c674\powdp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\powsp\c674\powsp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\recipdp\c674\recipdp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\recipsp\c674\recipsp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\rsqrtdp\c674\rsqrtdp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\rsqrtsp\c674\rsqrtsp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\sindp\c674\sindp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\sinsp\c674\sinsp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\sqrtdp\c674\sqrtdp_i.h    C/C++ Problem
#821 badly formed pragma    <Project Home>        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\sqrtsp\c674\sqrtsp_i.h    C/C++ Problem

Here are lines 47-49 of atan2sp_i.h:

47 #pragma CODE_SECTION (divspMod_atan2spi,    ".text:optci");
48 #pragma CODE_SECTION (atan2f_sr1i_atan2spi, ".text:optci");
49 #pragma CODE_SECTION (atan2sp_i,            ".text:optci");

Why the errors?

  • Mark,

    Are you building the program for C++?  If so, please see this forum post: http://e2e.ti.com/support/development_tools/compiler/f/343/t/72866.aspx

    Scott

  • Yes. Tried clicking on the link and copying and pasting the link but I get:

    Group Not Found

    Could you check the link and let me know. Thanks.

  • Mark,

    Can you try cutting and pasting the text of the link into your browser address bar? 

    I don't know why, but when I click on the link, or if I right click and "Copy link location" I get that group not found message too.  Maybe it has to do with it being on a different forum?  I'll have to find out, but hopefully a cut/paste will work for you...

    Scott

  • Tried both clicking and copying and pasting but no luck either way...if you find the correct link, let me know.

    Also, I'm hoping you can take a look at each of my posts today and provide some kind of insight to each problem. Thanks.

  • What browser are you using?

    This is the link:
    http://e2e.ti.com/support/development_tools/compiler/f/343/t/72866.aspx

    The text of the previous link shows the same, but hovering or clicking on it actually goes here (and gets the group not found message):
    http://e2e.ti.com/support/embedded/bios/f/355/support/development_tools/compiler/f/343/t/72866.aspx

    Another way to get there is to type "badly formed pragma" in the box in the upper right showing the text "Search Community".  Click on the "Everything" radio button, and then select the "Using Siglib DSP library" link that pops up.

    Scott

  • I'm using Firefox 13.01 and was able to get to the link. However, I can't say (or certainly don't understand) that it is clear what I need to do to clear these errors. I'm quite certain that I shouldn't have to modify any TI files which are the cause of my errors. I'll continue to read through the link...have you or has anyone at TI seen this problem and does someone have a suggestion of how to resolve it? Thanks.

  • Mark, I think this is the part of that thread that applies to your case. When you include any of the C libraries in your C++ code, use the following syntax:

    extern "C" {
    #include "atan2sp_i.h"
    }
    If you get further bad pragma errors, you may need to enclose additional header files in the same way.
  • I’m not familiar with the math library, and have not seen similar errors.  One of the options I saw on the different links that came up for a search on “badly formed pragma” was to enclose the include of the header in an extern “C” {}.  I don’t know if this is applicable for your case.  

    For this thread it seems it would be best to move it to the compiler forum.  I’ll ask that it be moved now…

    Scott

  • In one of my classes, I reference the mathlib.c file and have added the extern "C" as shown below:

    extern "C"
    {
        #include "mathlib.h"
    }

    I have also added the extern "C" around all the #includes in mathlib.h just to see if that might fix the problem but I get the same errors:

    Description    Resource    Path    Location    Type
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\atan2sp\c674\atan2sp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\atandp\c674\atandp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\atansp\c674\atansp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\cosdp\c674\cosdp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\cossp\c674\cossp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\divdp\c674\divdp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\divsp\c674\divsp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\exp10dp\c674\exp10dp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\exp10sp\c674\exp10sp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\exp2dp\c674\exp2dp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\exp2sp\c674\exp2sp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\expdp\c674\expdp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\expsp\c674\expsp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\log10dp\c674\log10dp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\log10sp\c674\log10sp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\log2dp\c674\log2dp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\log2sp\c674\log2sp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\logdp\c674\logdp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\logsp\c674\logsp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\powdp\c674\powdp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\powsp\c674\powsp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\recipdp\c674\recipdp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\recipsp\c674\recipsp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\rsqrtdp\c674\rsqrtdp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\rsqrtsp\c674\rsqrtsp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\sindp\c674\sindp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\sinsp\c674\sinsp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\sqrtdp\c674\sqrtdp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 47, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\sqrtsp\c674\sqrtsp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 48, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\atan2sp\c674\atan2sp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 48, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\atandp\c674\atandp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 48, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\atansp\c674\atansp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 48, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\exp10dp\c674\exp10dp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 48, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\exp10sp\c674\exp10sp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 48, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\exp2dp\c674\exp2dp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 48, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\exp2sp\c674\exp2sp_i.h    C/C++ Problem
    #821 badly formed pragma    Vibration Monitor        line 48, external location: C:\TI\mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\expdp\c674\expdp_i.h    C/C++ Problem

    Suggestions? Ideas?

  • I fixed the broken link in the earlier post.  But for convenience, here it is again.  The part of that thread most relevant here is summed up in this wiki article.

    On a possibly related note, the syntax ...

    extern "C" {
       #include "header.h" // C code header
    }

    does not cause all of the syntax and semantics of C++ to be changed to those of C.  It only indicates that the functions declared within that block are C functions.  C functions are called differently than C++ functions.  All the other conventions of C++, including those for #pragma, still apply. 

    Hope this helps ...

    -George

  • Hi,

    I have just experienced the same problem. I have also understood that the pragma-definition in the mathlib is for C only and that putting the include into "extern "C"" does not really help. Is there another way rather than porting my functions to pure C functions? This would really cause a lot of work since I relied on C++ in all my source files... I could also modify the pragma statements in the mathlib-headers, does anyone see any problem arising by doing so?

    By the way, the ".text:optci" section to which the functions shall be located during linking, do I need to reserve some space in my linker file or is this somehow handled in the mathlib internally? Is all of this described in the documentation of the mathlib? I did not see that..

    Thanks for any help and best regards

    H

  • I am actually wondering: Why would a CODE_SECTION pragma be required for an "inline" function? Is not there no space allocated for this function at a separate place other than in the context of the calling function anyway?

    H