未看到包含的头文件
Included header file is not being seen
编辑:新文件。我在访问Form1类中的公共函数时遇到问题。当我尝试使用标识符时,却找不到它。表格1:
#pragma once
#include "OpenGL.h"
#include "serialcom.h"
#include "calculations.h"
namespace GUI_1 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace OpenGLForm;
/// <summary>
/// Summary for Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
OpenGL = gcnew COpenGL(this->panel4, this->label16, 785, 530);
}
void changelabel2(float num)
{
label2 -> Text = " " + num;
}
protected: ...
OpenGL.h:
#include "stdafx.h"
#ifndef opengl
#define opengl
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <math.h>
// Declare globals
...
using namespace System::Windows::Forms;
namespace OpenGLForm
{
public ref class COpenGL: public System::Windows::Forms::NativeWindow
{
public:
COpenGL(System::Windows::Forms::Panel ^ parentForm, System::Windows::Forms::Label ^ lbl, GLsizei iWidth, GLsizei iHeight)
{
CreateParams^ cp = gcnew CreateParams;
c_p_v v1, v2;
changelabel2(189);
...
所以这不起作用(上面,在"changelabel2"中)。也许是因为我没有使用类名?
这是我的主要:
#include "stdafx.h"
#include <string.h>
#include <iostream>
#include <stdio.h>
#include < vcclr.h >
#include < stdio.h >
#include < stdlib.h >
#include < vcclr.h >
#include "Form1.h"
#include "calculations.h"
#include "serialcom.h"
using namespace GUI_1;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Form1^ form = gcnew Form1();
Application::Run(form);
return 0;
}
调用form.changelabel2也不起作用。
看起来OpenGL.h和Form1.h 之间存在循环依赖关系
如果可以的话,尝试删除#include "Form1.h"
,或者将其转换为类似class Form1;
的前向声明
此外,在标头中使用using namespace
时要小心,因为它会污染随后包含的任何文件的名称空间。
相关文章:
- 读取大文件(>2GB)(文本文件包含以太网数据)并通过不同参数随机访问数据的最佳方法是什么?
- C++文件包含多行
- CMake 如何强制third_party库将项目文件包含在当前项目源目录中?
- 是否可以将要"ShellExecute"的文件包含在 dll 中?如果是这样,"ShellExecute"中的文件位置应该是什么?
- C++ 逐行从文件(包含空格)读取数据
- 在 C++ 中,.h 文件包含文件但不起作用
- 生成的资源文件包含奇怪的包含文件
- 可变参数类的文件包含问题
- 为什么文件命令声明可执行文件包含"debug_info"
- 可以将标头文件包含在多个源文件中,而无需重复保护
- 为什么将.HPP文件包含在.h文件中
- Qt C++:将所有库文件包含在项目文件夹中
- 有条件地将文件包含在C++标头中
- 将多个原型文件包含在一个项目中会导致protobuf_AssignDescriptorsOnce()已经有一个主体
- 有没有办法将文件包含在C++中的所有项目文件中
- 将外部.asm文件包含到C++代码中
- 什么是"pch.h",为什么需要将其作为第一个头文件包含在内?
- 该头文件包含DirectX 12中的ThrowIfFailed()
- QT C :函数的多个定义当Header文件包含在MainWindow.h中时
- QT创建者错误地处理标头文件包含来自Directory