windowDimensions in error?

I have created the array windowDimensions with initialized values for [0] and[1]. I then placed these in the appropriated lines of code but every instance of this code (after the array) comes with the error messages

[{
“resource”: “/c:/Users/corne/GameDev/Dapper Dasher/Dasher.cpp”,
“owner”: “cpptools”,
“severity”: 4,
“message”: “narrowing conversion of ‘(nebula.Texture::width / 8)’ from ‘int’ to ‘float’ [-Wnarrowing]”,
“source”: “gcc”,
“startLineNumber”: 30,
“startColumn”: 32,
“endLineNumber”: 30,
“endColumn”: 32
},{
“resource”: “/c:/Users/corne/GameDev/Dapper Dasher/Dasher.cpp”,
“owner”: “cpptools”,
“severity”: 4,
“message”: “narrowing conversion of ‘(nebula.Texture::height / 8)’ from ‘int’ to ‘float’ [-Wnarrowing]”,
“source”: “gcc”,
“startLineNumber”: 30,
“startColumn”: 49,
“endLineNumber”: 30,
“endColumn”: 49
},{
“resource”: “/c:/Users/corne/GameDev/Dapper Dasher/Dasher.cpp”,
“owner”: “cpptools”,
“severity”: 4,
“message”: “narrowing conversion of ‘windowDimensions[0]’ from ‘int’ to ‘float’ [-Wnarrowing]”,
“source”: “gcc”,
“startLineNumber”: 31,
“startColumn”: 28,
“endLineNumber”: 31,
“endColumn”: 28
},{
“resource”: “/c:/Users/corne/GameDev/Dapper Dasher/Dasher.cpp”,
“owner”: “cpptools”,
“severity”: 4,
“message”: “narrowing conversion of ‘(windowDimensions[1] - (nebula.Texture::height / 8))’ from ‘int’ to ‘float’ [-Wnarrowing]”,
“source”: “gcc”,
“startLineNumber”: 31,
“startColumn”: 51,
“endLineNumber”: 31,
“endColumn”: 51
},{
“resource”: “/c:/Users/corne/GameDev/Dapper Dasher/Dasher.cpp”,
“owner”: “cpptools”,
“severity”: 4,
“message”: “unused variable ‘neb2Data’ [-Wunused-variable]”,
“source”: “gcc”,
“startLineNumber”: 38,
“startColumn”: 14,
“endLineNumber”: 38,
“endColumn”: 14
},{
“resource”: “/c:/Users/corne/GameDev/Dapper Dasher/Dasher.cpp”,
“owner”: “cpptools”,
“severity”: 4,
“message”: “narrowing conversion of ‘(nebula.Texture::width / 8)’ from ‘int’ to ‘float’ [-Wnarrowing]”,
“source”: “gcc”,
“startLineNumber”: 39,
“startColumn”: 32,
“endLineNumber”: 39,
“endColumn”: 32
},{
“resource”: “/c:/Users/corne/GameDev/Dapper Dasher/Dasher.cpp”,
“owner”: “cpptools”,
“severity”: 4,
“message”: “narrowing conversion of ‘(nebula.Texture::height / 8)’ from ‘int’ to ‘float’ [-Wnarrowing]”,
“source”: “gcc”,
“startLineNumber”: 39,
“startColumn”: 49,
“endLineNumber”: 39,
“endColumn”: 49
},{
“resource”: “/c:/Users/corne/GameDev/Dapper Dasher/Dasher.cpp”,
“owner”: “cpptools”,
“severity”: 4,
“message”: “narrowing conversion of ‘(windowDimensions[0] + 300)’ from ‘int’ to ‘float’ [-Wnarrowing]”,
“source”: “gcc”,
“startLineNumber”: 40,
“startColumn”: 30,
“endLineNumber”: 40,
“endColumn”: 30
},{
“resource”: “/c:/Users/corne/GameDev/Dapper Dasher/Dasher.cpp”,
“owner”: “cpptools”,
“severity”: 4,
“message”: “narrowing conversion of ‘(windowDimensions[1] - (nebula.Texture::height / 8))’ from ‘int’ to ‘float’ [-Wnarrowing]”,
“source”: “gcc”,
“startLineNumber”: 40,
“startColumn”: 57,
“endLineNumber”: 40,
“endColumn”: 57
},{
“resource”: “/c:/Users/corne/GameDev/Dapper Dasher/Dasher.cpp”,
“owner”: “cpptools”,
“severity”: 4,
“message”: “unused variable ‘nebData’ [-Wunused-variable]”,
“source”: “gcc”,
“startLineNumber”: 29,
“startColumn”: 14,
“endLineNumber”: 29,
“endColumn”: 14
}]

Narrowing conversions are usually just warnings to let you know that there could be some data loss from converting to a narrower type.

In this case, going from int-to-float. Since an int can actually hold a higher value than floats you could potentially lose some data, though in our case this would never actually happen.

You can either ignore it, or you can make sure the resulting calculation returns a float. One option to do this is with casting, (float)windowDimensions[0] for example.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms