English 中文(简体)
警告:声明没有效力(C++)
原标题:warning: statement has no effect (C++)
  • 时间:2011-10-31 09:12:09
  •  标签:
  • c++

我有以下法典:

void CScriptTable::EnumReferences(asIScriptEngine *engine)
{
    if (m_table)
    {   
        // Call the gc enum callback for each nested table      
        size_t col = 0, row = 0, num_cols = m_table->numCols(), num_rows = m_table->numRows();

        for( col; col < num_cols; col++ )   // Line 92
        {   
            if (m_table->getColType(col) == COL_TABLE) {
                for (row; row < num_rows; row++){  // Line 95
                    Table * tbl = m_table->getTable(row, col);
                    engine->GCEnumCallback(tbl);
                }   
            }   
        }   
    }   
}

When compiling, (g++), the warning (statement has no effect) is issued for line 92 & 95 (indicated in the snippet above)

我不明白,为什么他们没有效果,尽管我当时正在挨饿,但是,如果他们能够发现我所失踪的人的话,他们会与第二手眼睛相干。

最佳回答

If guess you want to iterate over all columns and for each of them over all rows. so better change your code to something like this:

居乐团的第一份声明一经执行,即是在 lo首时。 由于你想把每栏的零号加起来,你必须每栏的行号为0:

void CScriptTable::EnumReferences(asIScriptEngine *engine)
{
    if (m_table)
    {   
        // Call the gc enum callback for each nested table      
        size_t num_cols = m_table->numCols(), num_rows = m_table->numRows();

        for(size_t col = 0; col < num_cols; col++ )   // Line 92
        {   
            if (m_table->getColType(col) == COL_TABLE) {
                for (size_t row = 0; row < num_rows; row++){  // Line 95
                    Table * tbl = m_table->getTable(row, col);
                    engine->GCEnumCallback(tbl);
                }   
            }   
        }   
    }   
}
问题回答

它涉及《指南》(<>col/code>和row,部分内容是《指南》的初始部分。 这些言论没有任何意义。 仅删除:

for( ; col < num_cols; col++)
for( col; col < num_cols; col++ )

col;

这没有任何效果。 你们必须向其分配一些东西,或者根本不写。 既然你把它排除在你的圈子之外,你就迫切需要留下空洞的“<>条码”;

各位再次收到这些警告,因为在<><<>>>>>> 编码栏目中的初始化说明是没有:

for(col; col < num_cols; col++)  // line 92: "col" has no effect
for(row; row < num_rows; row++)  // line 95: "row" has no effect

由于你已经将这些变数排在外面,你可能想将其从<>条码>上删除:

for(; col < num_cols; col++)  // line 92
for(; row < num_rows; row++)  // line 95

然而,在这方面最好做的是,将<<>>>><中的变量本身而不是放在外:

// Call the gc enum callback for each nested table
size_t num_cols = m_table->numCols(), num_rows = m_table->numRows();

for(size_t col = 0; col < num_cols; col++ )   // Line 92
{   
    if (m_table->getColType(col) == COL_TABLE) {
        for (size_t row = 0; row < num_rows; row++){  // Line 95
            Table * tbl = m_table->getTable(row, col);
            engine->GCEnumCallback(tbl);
        }   
    }   
}

如果你真的想要在您的周期中打上变数(可能的话)的话,就会改变:

for( col; col < num_cols; col++ )

to something like this:

for( col = col; col < num_cols; col++ )

两者兼有。 它应当从事这项工作。

我的猜测是,你只能使用你。

for(; col < num_cols; col++ )   // Line 92

以及

for (; row < num_rows; row++) {  // Line 95




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签