Professional Web Applications Themes

Howto disable strict type checking ? - Mac Programming

Is there a way to disable the strickness of type checking in CW? Thx....

  1. #1

    Default Howto disable strict type checking ?

    Is there a way to disable the strickness of type checking in CW?

    Thx.


    Denis Guest

  2. #2

    Default Re: Howto disable strict type checking ?

    In article <vif.com>, "Denis Work" <net>
    wrote:
     

    What are you trying to accomplish?

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

  3. #3

    Default Re: Howto disable strict type checking ?

    In article <vif.com>,
    "Denis Work" <net> wrote:
     

    You can turn off ANSI strict, but C++ still has very strict type
    checking. You really should be thankful and fix any typechecking
    errors, this is one of the better things and can prevent serious
    problems in the life of a program.

    Ron

    --
    Metrowerks, one of the worldıs top 100 companies and influencers
    in the software development industry. - SD Times May 2004
    http://www.sdtimes.com/2004sdt100.htm

    Metrowerks, maker of CodeWarrior
    Ron Liechty - com - http://www.metrowerks.com
    MW Guest

  4. #4

    Default Re: Howto disable strict type checking ?

    To Ron and meeroh,

    The thing I need to do is I have a lot of code to port and I know it is
    working even thaught in other compiler it generates warnings... But running
    stable...

    On CW, those generates errors and prevent me from looking at the big
    picture. I would have no problem if that features was constraint in release
    mode, but in debug it should be a choice or defaulted to disabled.
    Beside I see that use of uninitialized var is just a warning, That one
    should be an error.

    The thing is : I want to be able to build ASAP in a first stage,
    then I would be able to go check upon those details, especially since those
    are of compatible type.


    Thanks,
    DC


    "MW Ron" <com> wrote in message
    news:newsguy.com... 
    >
    > You can turn off ANSI strict, but C++ still has very strict type
    > checking. You really should be thankful and fix any typechecking
    > errors, this is one of the better things and can prevent serious
    > problems in the life of a program.
    >
    > Ron
    >
    > --
    > Metrowerks, one of the worldıs top 100 companies and influencers
    > in the software development industry. - SD Times May 2004
    > http://www.sdtimes.com/2004sdt100.htm
    >
    > Metrowerks, maker of CodeWarrior
    > Ron Liechty - com - http://www.metrowerks.com[/ref]


    Denis Guest

  5. #5

    Default Re: Howto disable strict type checking ?

    In article <vif.com>,
    "Denis Work" <net> wrote:
     

    Don't use that other compiler again :) My point is still the same, even
    if it is running stable now, you may have difficulties in the future.
    C++ strong type checking is a very good thing and not something to be
    dismissed simply because it is inconvenient.

    I'll bet you will find that a lot of your errors are void pointers and
    on const/volatile items and these are good things to catch and fix.
     

    It is not illegal just silly, but you can make this an error by pragma
    or by setting this in the Warnings Windows

     

    Just to be clear, you want something like this prgama (an error for an
    illegal conversion that is deprecated) for all conversions.

    #pragma no_conststringconv on | off | reset (default: off)

    when on
    #pragma no_conststringconv on
    *cp = "Hello World";
    Error : illegal implicit conversion from 'const char[12]' to
    'char *'
    Test.cp line 3 char *cp = "Hello World";

    I don't think you can do that because you just can't selectively decide
    which parts of the standard to ignore :0

    Finally, perhaps you can do some files as C which would get rid of most
    of the conversion problems.

    Ron 
    >>
    >> You can turn off ANSI strict, but C++ still has very strict type
    >> checking. You really should be thankful and fix any typechecking
    >> errors, this is one of the better things and can prevent serious
    >> problems in the life of a program.
    >>
    >> Ron
    >>
    >> --
    >> Metrowerks, one of the worldıs top 100 companies and influencers
    >> in the software development industry. - SD Times May 2004
    >> http://www.sdtimes.com/2004sdt100.htm
    >>
    >> Metrowerks, maker of CodeWarrior
    >> Ron Liechty - com - http://www.metrowerks.com[/ref]
    >
    >[/ref]

    --
    Metrowerks, one of the worldıs top 100 companies and influencers
    in the software development industry. - SD Times May 2004
    http://www.sdtimes.com/2004sdt100.htm

    Metrowerks, maker of CodeWarrior
    Ron Liechty - com - http://www.metrowerks.com
    MW Guest

  6. #6

    Default Re: Howto disable strict type checking ?

     
    That compiler happends to be: XCode, Borland C++ Builder, and Visual
    Studio...
    And I don't think you can just get rid of every body else because some
    people think is a good idea.
    Even if it is a good thing, there bound to be exception...
    As an ogy, it is like having a dictionary embeded in your word processor
    and refuse to let you type anything that is not in that dictionary.

     
    (not necessarily), Quite the opposite actually,
    when you have to cast to get rid of a "warning" (an error in this case)
    You prevent the compiler from doing it's job by masking, disguise what the
    type really is.
    Therefore the compiler will not be able any more to warn you,
    nor turn it into an error when the fundamental of the type changes.
    That is what the compilers do.

    To reuse your example...
    char ThisString [32];

    PTSTR ThisStr;

    if PTSTR is a typedef that revert to a char *;
    ThisStr = ThisString; // should not even raise a warning.

    but if I have to cast it, here what is going to happen:
    ThisStr = (PTSTR)ThisString;

    If PTSTR become a unistring * then the compiler will not be able to warn you
    anymore.
    because you prevent the compiler of seeing the char ThisString []
    defenition.

    And that is a bigger problem.

     
    In debug mode yes it should be.

    When you end up with tones of code from another planet,
    you might want to see how it behave first in this new compile env.

     
    Not necessarily a priority one.

     
    I know that...
    But my point is you are much likelly to have problem with this one than the
    other.

     

    How's about extern 'C' { ?



    "MW Ron" <com> wrote in message
    news:newsguy.com... [/ref]
    running 
    >
    > Don't use that other compiler again :) My point is still the same, even
    > if it is running stable now, you may have difficulties in the future.
    > C++ strong type checking is a very good thing and not something to be
    > dismissed simply because it is inconvenient.
    >
    > I'll bet you will find that a lot of your errors are void pointers and
    > on const/volatile items and these are good things to catch and fix.
    > [/ref]
    release 
    >
    > It is not illegal just silly, but you can make this an error by pragma
    > or by setting this in the Warnings Windows
    >
    > [/ref]
    those 
    >
    > Just to be clear, you want something like this prgama (an error for an
    > illegal conversion that is deprecated) for all conversions.
    >
    > #pragma no_conststringconv on | off | reset (default: off)
    >
    > when on
    > #pragma no_conststringconv on
    > *cp = "Hello World";
    > Error : illegal implicit conversion from 'const char[12]' to
    > 'char *'
    > Test.cp line 3 char *cp = "Hello World";
    >
    > I don't think you can do that because you just can't selectively decide
    > which parts of the standard to ignore :0
    >
    > Finally, perhaps you can do some files as C which would get rid of most
    > of the conversion problems.
    >
    > Ron 
    > >
    > >[/ref]
    >
    > --
    > Metrowerks, one of the worldıs top 100 companies and influencers
    > in the software development industry. - SD Times May 2004
    > http://www.sdtimes.com/2004sdt100.htm
    >
    > Metrowerks, maker of CodeWarrior
    > Ron Liechty - com - http://www.metrowerks.com[/ref]


    Denis Guest

  7. #7

    Default Re: Howto disable strict type checking ?

    In article <vif.com>,
    "Denis Work" <net> wrote:
     
    >That compiler happends to be: XCode, Borland C++ Builder, and Visual
    >Studio...[/ref]

    I'm doubting you now. This is not Metrowerks standard this is the
    ISO/ANSI C++ standard, and I bet they also impose the same level in
    their recent compilers. Perhaps they are compiling as C.
     

    It is not some people it is the requirements of C++. We had warnings
    for years and then changed , it is not like this is a recent
    development. We always put a warning in first.
     
    >(not necessarily), Quite the opposite actually,
    >when you have to cast to get rid of a "warning" (an error in this case)
    >You prevent the compiler from doing it's job by masking, disguise what the
    >type really is.
    >Therefore the compiler will not be able any more to warn you,
    >nor turn it into an error when the fundamental of the type changes.
    >That is what the compilers do.
    >
    >To reuse your example...
    >char ThisString [32];
    >
    >PTSTR ThisStr;
    >
    > if PTSTR is a typedef that revert to a char *;
    > ThisStr = ThisString; // should not even raise a warning.
    >
    >but if I have to cast it, here what is going to happen:
    > ThisStr = (PTSTR)ThisString;
    >
    >If PTSTR become a unistring * then the compiler will not be able to warn you
    >anymore.
    >because you prevent the compiler of seeing the char ThisString []
    >defenition
    >
    >And that is a bigger problem.[/ref]

    Which is why you do not use forced casts in C++.

    My question has to be which rules do we not enforce?

    Ron

    --
    Metrowerks, one of the worldıs top 100 companies and influencers
    in the software development industry. - SD Times May 2004
    http://www.sdtimes.com/2004sdt100.htm

    Metrowerks, maker of CodeWarrior
    Ron Liechty - com - http://www.metrowerks.com
    MW Guest

  8. #8

    Default Re: Howto disable strict type checking ?

    My respond inline.

    "MW Ron" <com> wrote in message
    news:newsguy.com... 
    > >That compiler happends to be: XCode, Borland C++ Builder, and Visual
    > >Studio...[/ref]
    >
    > I'm doubting you now. This is not Metrowerks standard this is the
    > ISO/ANSI C++ standard, and I bet they also impose the same level in
    > their recent compilers. Perhaps they are compiling as C.
    >[/ref]
    No it is their latest and greatest compiler. Even XCode (last version) does
    it...
    I am not saying that there is no warnings, but it build it.

     
    >
    > It is not some people it is the requirements of C++. We had warnings
    > for years and then changed , it is not like this is a recent
    > development. We always put a warning in first.
    >[/ref]
    A warning is fine, I have no problem when it is a warning...
    I am the first to go look up those to make sure there fine.
     
    > >(not necessarily), Quite the opposite actually,
    > >when you have to cast to get rid of a "warning" (an error in this case)
    > >You prevent the compiler from doing it's job by masking, disguise what[/ref][/ref]
    the [/ref]
    you 
    >[/ref]
     
    I beg your pardon! Then what do you do with the problem above?

     
    I don't understand your last question.

    DC


    Denis Guest

  9. #9

    Default Re: Howto disable strict type checking ?

    In article <vif.com>, "Denis Work" <net>
    wrote:
     

    Regarding uninitialized vars, the compiler vendor doesn't get to decide what's
    an error -- the language spec does, and uninitialized vars are not errors
    according to the C and C++ specs.

    Regarding your actual errors, please show us some code _and_ the errors it
    generates. The one example you gave does not give me an error or a warning.

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

  10. #10

    Default Re: Howto disable strict type checking ?

    Here it is:


    OSStatus MacWindow::InstallEventHandler(const EventTypeSpec events[], int
    count)
    {
    ::InstallWindowEventHandler(m_hWnd, NewEventHandlerUPP(EventHandler),
    count, events, this, NULL);
    return NO_ERROR;
    }

    The return from NewEventHandlerUPP(EventHandler) generate an error in CW but
    not in XCode.


    DC





    "Miro Jurisic" <org> wrote in message
    news:mit.edu... 
    <net> [/ref]
    running [/ref]
    release 
    >
    > Regarding uninitialized vars, the compiler vendor doesn't get to decide[/ref]
    what's 
    warning. 


    Denis Guest

  11. #11

    Default Re: Howto disable strict type checking ?

    In article <vif.com>, "Denis Work" <net>
    wrote:
     

    I asked you to show us the code and the errors. Do so, because I can't help you
    if you don't.

    I had to fake up some bits to get this to compile, but this slightly modified
    code compiles without any problem for me:

    pascal OSStatus
    EventHandler(
    EventHandlerCallRef inCallRef,
    EventRef inEvent,
    void* inUserData);

    OSStatus MacWindow__InstallEventHandler(const EventTypeSpec events[], int
    count)
    {
    void* this_dummy;
    WindowRef m_hWnd;
    ::InstallWindowEventHandler(m_hWnd, NewEventHandlerUPP(EventHandler),
    count, events, this_dummy, NULL);
    return 0;
    }

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

  12. #12

    Default Re: Howto disable strict type checking ?

    Sorry,
    The reason is I cannot rebuild at all at this time because I am in a middle
    (having a hard time too) integrating serial device code so the code snipet I
    gave to you was base purely on one I remembered.

    Anyhow here is my EventHandler defenition:

    OSStatus MacWindow::EventHandler(EventHandlerCallRef call, EventRef
    ThisEvent, PVOID ThisData)
    {
    MacWindow *ThishWnd = (MacWindow*)ThisData;

    return ThishWnd ? ThishWnd->HandleEvent(call, ThisEvent) :
    eventNotHandledErr;
    }
    The only difference I see here is the PVOID -> typedef void * PVOID and the
    call protocol which is suppose to be the default;

    BTW: Would you happen to know anything about integrating serial device
    support with CW.
    I cannot call standard read(...) and write(...) the compiler says they are
    undefine!?!


    Thanks,
    P.s. As I am relativelly knew programming on this system and CW I must rely
    a lot on others sample code.
    I do not find many books on the subject. about CW I found none. So the code
    you've seen I took from XCode doc or Apple web site... I probaly have change
    the type (PVOID) to make it clearer. Like I said XCode builded it without a
    foss.
    DC





    "Miro Jurisic" <org> wrote in message
    news:mit.edu... 
    <net> [/ref]
    int [/ref]
    NewEventHandlerUPP(EventHandler), [/ref]
    but 
    >
    > I asked you to show us the code and the errors. Do so, because I can't[/ref]
    help you 
    modified 


    Denis Guest

  13. #13

    Default Re: Howto disable strict type checking ?

    In article <vif.com>, "Denis Work" <net>
    wrote:
     

    You are missing "pascal" at the beginning of this declaration. I am assuming
    that the function is a static class member, based on the way it's written, but
    you should make sure that it is.
     

    That's because Xcode ignores the pascal keyword, whereas CW enforces it in
    prototypes. You can debate which is right on Mac OS X until the cows come home.

    hth

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

  14. #14

    Default Re: Howto disable strict type checking ?

    So what you saying is the problem come from the pascal declaration missing
    instead of the PVOID.

    That make sense, I will check that, but you would agree with me a more
    specific verbose either warning or error would have help any how.

    I am not familiar with the expression "until the cows come home"
    The debate was about the strict error which the compiler being flexible
    enough to either make it a warning.
    The other thing I might add on this subject, If your are right about the
    pascal declaration,
    Then a very good compiler should even refuse the cast because the
    fundamental as changed.
    Then I guess that would start a mess, because all those memory blocks often
    changed from a WORD ptr to a DWORD ptr would also failed... hahaha!

    Denis


    "Miro Jurisic" <org> wrote in message
    news:mit.edu... 
    <net> 
    >
    > You are missing "pascal" at the beginning of this declaration. I am[/ref]
    assuming 
    but 
    >
    > That's because Xcode ignores the pascal keyword, whereas CW enforces it in
    > prototypes. You can debate which is right on Mac OS X until the cows come[/ref]
    home. 


    Denis Guest

  15. #15

    Default Re: Howto disable strict type checking ?

    In article <vif.com>,
    "Denis Work" <net> wrote:
     

    But the only example I saw you give was OS-10 specific. I wasn't aware
    Borland C++ Builder was available for Mac OS 10 or that it had pascal
    calling conventions for Carbon Event handlers.
     

    I very much doubt that you will see significant differences between any
    of these compilers in what they see as an error in C++ code, unless you
    turn on compiler-specific options.
     

    A good reason to avoid casts. If you find you are casting just to shut
    the compiler up, then you may be casting for the wrong reason.
     

    Why would you cast if you don't need to? "char* ThisStr = ThisString;"
    compiles just fine with CW, with no warning.
     

    Again a good reason not to cast--*especially* not blindly so with
    C-style casts.

     

    There are differences between compilers to be sure, but the vast
    majority of code that generates an error on one conforming C++ compiler
    will do so on nearly all of them.


    -Chad
    Chad Guest

  16. #16

    Default Re: Howto disable strict type checking ?


    "Chad J McQuinn" <andthistoo.insightbb.com> wrote in message news:comcast.net... 
    >
    > But the only example I saw you give was OS-10 specific. I wasn't aware
    > Borland C++ Builder was available for Mac OS 10 or that it had pascal
    > calling conventions for Carbon Event handlers.
    > [/ref]
    No unfortunatelly, I am already confortable with it.
     
    >
    > I very much doubt that you will see significant differences between any
    > of these compilers in what they see as an error in C++ code, unless you
    > turn on compiler-specific options.
    > [/ref]
    Perhaps, but they let you fine tune the implementation (play with the rules, a little).
    ANSI, as many other is a work in progress old code 10 yrs ago would not be aware of those new rules.
    Beside, freedom is always a better politic than even the most well intetion constraint.
     
    >
    > A good reason to avoid casts. If you find you are casting just to shut
    > the compiler up, then you may be casting for the wrong reason.
    > [/ref]
    My point ecxactly.
     
    >
    > Why would you cast if you don't need to? "char* ThisStr = ThisString;"
    > compiles just fine with CW, with no warning.
    > [/ref]
    Yeah, I notice that, it was a wrong example, you see I did not have the error in my face at the time.
    And I was merely making a point.
     
    >
    > Again a good reason not to cast--*especially* not blindly so with
    > C-style casts.[/ref]

    I was just trying to make that point ecxactly...
     
    >
    > There are differences between compilers to be sure, but the vast
    > majority of code that generates an error on one conforming C++ compiler
    > will do so on nearly all of them.[/ref]

    Not in my experience. But somethimes you just want a view "d'ensemble" before starting rewriting somebody else code, and there would be reason to disable some of those contournable error during that period.
    Like I said before, I would not have a problem that they were fixed at release, but at debug a little bit of freedom would be nice.

    Denis



    Denis Guest

  17. #17

    Default Re: Howto disable strict type checking ?

    In article <vif.com>, "Denis Work" <net>
    wrote:
     

    The missing pascal declaration is a problem. If PVOID declaration is also
    missing, that's also a problem, of course.
     

    CW could certainly be more helpful in this case.
     

    It means "as long as you wish, and nothing good will come out of it", basically.
    It was not meant to imply you were debating that, but I mentioned it because
    I've seen that debate come up in a few different places, with no useful outcome.

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

  18. #18

    Default Re: Howto disable strict type checking ?

    Thanks, that was instructive... all of it.

    Denis

    "Miro Jurisic" <org> wrote in message
    news:mit.edu... 
    <net> [/ref]
    missing 
    >
    > The missing pascal declaration is a problem. If PVOID declaration is also
    > missing, that's also a problem, of course.

    >
    > CW could certainly be more helpful in this case.

    >
    > It means "as long as you wish, and nothing good will come out of it",[/ref]
    basically. 
    because 
    outcome. 


    Denis Guest

  19. #19

    Default Re: Howto disable strict type checking ?

    On this topic I have an error which left me stunt...
    This one is for real.

    Error : (10248) function call 'StringCopy({lval} char[1024], {lval}
    unsigned char[256], unsigned long)' does not match

    'StringCopy(char *, const char *, int)'

    DG_Control.cpp line 265 Name, sizeof(TwainInfo.FileName));

    Project: DocuPen, Target: DocuPen, Source File: DG_Control.cpp



    Here is the def:

    ////////////////////////////////////////////////////////////////////////////
    ///////////////////////


    typedef char * PTSTR;

    typedef const char * PCTSTR ;




    int StringCopy (PTSTR Dest, PCTSTR Src, int MaxCount )
    {
    ....

    }

    Why is that an error?



    I would understand a warning thaugh, but an error, why?

    Is it because of the unsigned long from sizeof(TwainInfo.FileName)?

    Is it because {lval} char[1024]?

    Is it because {lval} unsigned char[256]?





    Denis






    Denis Guest

  20. #20

    Default Re: Howto disable strict type checking ?

    In article <vif.com>,
    "Denis Work" <net> wrote:
     

    Your second parameter to to StringCopy() does not match types.
     

    No.
     

    No.
     

    Yes. Are you passing in a Str255 type?

    --
    Isaac Wankerl
    Metrowerks
    Isaac Guest

Page 1 of 3 123 LastLast

Similar Threads

  1. Replies: 3
    Last Post: October 18th, 06:56 AM
  2. Replies: 2
    Last Post: October 16th, 08:29 AM
  3. Howto Disable Messenger Service Pop-ups
    By Jupiter Jones [MVP] in forum Windows Setup, Administration & Security
    Replies: 2
    Last Post: July 23rd, 02:44 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139