C26444 - Unnamed Objects Warning

In the 'Shader.cpp' file of my program, I get the C26444 warning - 'Avoid unnamed objects with custom construction and destruction.' on the line:

 
GLCheck(&Shader::ParseAlternate, this, Shaders, filepath);

I don't understand where this warning is coming from, could anyone offer advice on what might be causing this warning, and how to eliminate it?

I have tried to include only the necessary parts of the program to avoid bloating:

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
//-------------------------------------
// Main:
//-------------------------------------
#include "Errors/Errors.h"
#include "Shader/Shader.h"
#include "Overload/Overload.h"

int main()
{
  Shader shader("Source/Shader/GL.shader");
}
//-------------------------------------

//-------------------------------------
// Overload.h:
//-------------------------------------
#pragma once
#include "Shader/Shader.h"
#include "Errors/Errors.h"

typedef void (Shader::*type5) (string_pair&, const char*);
void GLCheck(type5, Shader*, string_pair&, const char*);
//-------------------------------------

//-------------------------------------
// Overload.cpp:
//-------------------------------------
#include "Overload.h"

void GLCheck(type5 function, Shader* object, string_pair& shaders, const char* filepath)
{
	GLClearErrors();
	(object->*function) (shaders, filepath);
	GLCheckErrors(NAMEOF(function), __FILE__, __LINE__);
}
//-------------------------------------

//-------------------------------------
// Shader.h:
//-------------------------------------
typedef std::pair<std::string, std::string> string_pair;

class Shader
{
        // members...

	void ParseAlternate(string_pair&, const char*);
	
        // other member functions...

public:
	Shader(const char*);

        // other member functions...

};
//-------------------------------------

//-------------------------------------
// Shader.cpp:
//-------------------------------------
#include "Shader.h"
#include "Overload/Overload.h"

void Shader::ParseAlternate(string_pair& shaders, const char* filepath)
{
	enum WhichShader { NoShader, VertexShader, FragmentShader };
	WhichShader shader_type{ NoShader };

	std::ifstream file;
	std::string line;

	file.open(filepath);
	if (!file.is_open())
	{
		std::cout << "Error opening file at: " << filepath << std::endl;
		__debugbreak();
	}
	while (std::getline(file, line, '\n')) // reads from file and outputs data into line
	{
		if (line.find("#vertex") != std::string::npos)
		{
			shader_type = WhichShader::VertexShader;
			continue;
		}
		else if (line.find("#fragment") != std::string::npos)
		{
			shader_type = WhichShader::FragmentShader;
			continue;
		}

		if (shader_type == WhichShader::VertexShader)
			shaders.first += line + '\n';
		else if (shader_type == WhichShader::FragmentShader)
			shaders.second += line + '\n';
	}
}

Shader::Shader(const char* filepath)
	: m_ProgramID(0), m_UniformLocationCache()
{
	string_pair Shaders;
	
	// Create shaders:
	unsigned int VertexShader   = GLCheck(&Shader::CreateShader, this, GL_VERTEX_SHADER);
	unsigned int FragmentShader = GLCheck(&Shader::CreateShader, this, GL_FRAGMENT_SHADER);
	
	GLCheck(&Shader::ParseAlternate, this, Shaders, filepath);

	// Compile shaders:

	// Create program:

	// Attach shaders:

	// Link program:

	// Detach shaders:

	// Validate program:
}
//------------------------------------- 

Thanks in advance.
Last edited on
Grand Master stickshift said
double click the error and tell me which line the compiler thinks the error is at.

I reloaded the program and the error seems to have disappeared now, might have just been one of those occasions where the green line refuses to vanish until you close the program. If it reappears I will update with the line that the compiler sees the error at. Thanks anyway.
Last edited on
Topic archived. No new replies allowed.