意外的标识符char [32]

时间:2019-06-12 17:40:26

标签: visual-studio c++11

所以我在vs 2017中遇到了意外的标识符错误。 错误列表表明此段代码是问题所在:

<html>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.9/angular.min.js"></script>
<body ng-app="mainApp">
<form class="search_form" onsubmit="return false;">
<div ng-controller="searchController">
<div id="tags">
<input type="text" required placeholder="Hashtags go here.." onfocus="this.placeholder = ''" onblur="this.placeholder = 'Hashtags go here..'"  style="text-align: left; border-bottom: 1px solid #757575" name="input_field" id="input_field" ng-model="input_field" class="keywordTag" ng-keydown="search($event)"/>
<div class="bar"></div>
</div>
</body>
</html>

char [32]部分是带红色下划线的部分。 谢谢 编辑: 我也得到

       Private Sub edittbCensus()
    Try
        If con.State = ConnectionState.Closed Then
            con.Open()
        End If
        If tbRecord.Text <> "" And tbName.Text <> "" And tbAddress.Text <> "" And tbPurpose.Text <> "" And tbOthers.Text <> "" And tbCTC.Text <> "" And tbAt.Text <> "" And tbOn.Text <> "" And tbOR.Text <> "" Then
            sql = "update tbBarangayClearance set Name = '" & tbName.Text & "'," & "Address = '" & tbAddress.Text & "'," & "Purpose = '" & tbPurpose.txt & "'," & "Others = '" & tbOthers.Text & "'," & "CTC = '" & tbCTC.Text & "'," & "IssuedAt = '" & tbAt.Text & "'," & "IssuedOn = '" & tbOn.Text & "'," & "OR = '" & tbOR.Text & "'" & "where Record =" & CInt(tbRecord.Text) & ""

            Dim cmd As OleDbCommand = New OleDbCommand(sql, con)

            Try
                cmd.ExecuteNonQuery()
                cmd.Dispose()
                con.Close()
                MessageBox.Show("Update Successful")
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        Else
            MessageBox.Show("One or more Fields are left Blank")
        End If
    Catch ex As Exception
        MessageBox.Show(ex.ToString)
    End Try
End Sub

NETVAR("CBaseAttributableItem", "m_szCustomName", GetCustomName, char [32]);

好吧,因为我不能在不键入im的情况下发布这么多代码,只是在这里解释了一些内容NETVAR用于获取游戏中变量的地址,例如用于修改或读取它们的运行状况。如果您需要其他定义 也要在评论中问我,尽管这是一个语法错误,但是代码含义可能不是很多 Idk im kinda new ,所以 我也将Vs 2017与工具箱v141和sdk 10.0.17763.0一起使用

syntax error: '['  

带有netvar func的头文件:

unexpected token(s) preceding '{'; skipping apparent function body

编辑2:我删除了[32],它编译得很好,但是程序本身没有工作

1 个答案:

答案 0 :(得分:0)

因此,我们怀疑问题在于NETVAR的定义方式:

type& func_name( ) { \

此行将尝试返回char[32],这不是方法的有效返回类型。删除[32]并不能解决问题,因为这丢失了您实际上需要一个指向变量的指针的事实,因为您要返回的不是char而是char*。您可以尝试使用NETVAR_PTR并返回正确的值,但是需要将char而不是char[32]传递给type参数。这将返回char*,并且您必须小心不要写超过31个字符并自己维护空终止符。

值得注意的是,这完全取决于ABI,如果因为Windows上ABI并不是最稳定的东西而中断,也不要感到惊讶。

值得注意的是,某些cleaver模板编程可以使用类型特征解决返回类型问题:

std::conditional_t<std::is_array_v<type>, std::decay_t<type>, type> func_name \

这有条件地是指针还是最初传递的任何类型,具体取决于它是否是数组。