Some C++ Keyword Not Detected



  • hi in "C++ Reference":http://www.cppreference.com/wiki/keywords/start @and@ is c++ keyword but qt doesn't know it as c++ keyword!
    how can i add it to qt c++ editor this keyword.
    i also use "Generic highlight " but i find that it's not work for c++ and QML and it's just work for other language that qt not create an official engine for it!



  • I suggest you file a bugreport in "Jira":http://bugreports.qt.nokia.com on this.



  • ok file it on Jira you can find it "here":http://bugreports.qt.nokia.com/browse/QTCREATORBUG-5169



  • The problem here is, that "and" is an alias for "&&" and is therefore highlighted just as the operator it stands for (in this case not at all). I think this is the correct behavior.



  • ok you are write the qt detect it as operator but Indeed and it's not an operator and it's a c++ keyword!
    it's just a bug reason!



  • It is an operator. Using and would cause the operator&&() method to be called if overloaded. Every operator is also a keyword, but not every keyword is an operator.

    EDIT: I probably used keyword incorrectly here, what I actually meant is closer to token (See my next post on the for the definition of keyword in the c++ standard)



  • no ! is + is a keyword?
    and you can see all reference for this that say and is a keyword ! why you want to fight when all reference say the true



  • I'm sorry, I probably formulated that incorrectly. I think it's not our decision to make (we'll see what the Qt developers say). A little more information on what I base my opinion. From the standard (Section 2.12.1):
    [quote]
    The identifiers shown in Table 3 are reserved for use as keywords (that is, they are unconditionally treated
    as keywords in phase 7) except in an attribute-token (7.6.1) [ Note: The export keyword is unused but is
    reserved for future use. — end note ]:
    Table 3 — Keywords
    alignof
    asm
    auto
    bool
    break
    case
    catch
    char
    char16_t
    char32_t
    class
    const
    constexpr
    const_cast
    continue
    decltype
    default
    delete
    do
    double
    dynamic_cast
    else
    enum
    explicit
    export
    extern
    false
    float
    for
    friend
    goto
    if
    inline
    int
    long
    mutable
    namespace
    new
    noexcept
    nullptr
    operator
    private
    protected
    public
    register
    reinterpret_cast
    return
    short
    signed
    sizeof
    static
    static_assert
    static_cast
    struct
    switch
    template
    this
    thread_local
    throw
    true
    try
    typedef
    typeid
    typename
    union
    unsigned
    using
    virtual
    void
    volatile
    wchar_t
    while
    [/quote]
    In my opinion, even though the aliases are reserved and cannot be used as variable names, they should not be highlighted the same way as the ones that are explicitly called keywords, but rather like operators, as they behave and are used exactly as such:

    As you can see in the following two exerts from the standard, the aliases are defined as operators (1st quote), even though it is noted in the keywords section, that they should be not used as variable names (2nd quote)

    [quote]
    The lexical representation of C++ programs includes a number of preprocessing tokens which are used in
    the syntax of the preprocessor or are converted into tokens for operators and punctuators:
    preprocessing-op-or-punc: one
    {
    }
    [
    <:
    :>
    <%
    new delete
    ?

    !

    <
    ˆ=
    &=
    |=
    <=

    =
    &&
    and and_eq
    bitand
    or
    or_eq
    xor
    of
    ]
    %>
    ::
    /

    <<
    ||
    bitor
    xor_eq

    %:
    .
    %
    +=

    ++
    compl

    %:%:
    .*
    ˆ
    -=

    =
    --
    not
    (
    ;
    )
    :
    &
    =
    <<=
    ,
    not_eq
    |
    /=
    ==
    ->

    ...

    %=
    !=
    ->
    [/quote]

    [quote]
    Furthermore, the alternative representations shown in Table 4 for certain operators and punctuators (2.6)
    are reserved and shall not be used otherwise:
    Table 4 — Alternative representations
    and
    not_eq
    and_eq
    or
    bitand
    or_eq
    bitor
    xor
    compl
    xor_eq
    not
    [/quote]



  • can you link your reference



  • I was referring to the ISO/IEC 14882 (C++ standard) available as direct download "here":http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3092.pdf or as a draft from February 2011 "here":http://open-std.org/JTC1/SC22/WG21/docs/papers/2011/n3242.pdf. You can find the project page (with other specifications) "here":http://open-std.org/JTC1/SC22/WG21/docs/projects#14882

    EDIT: Warning! Big PDF files (10MB)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.