I'm getting the error
Cannot Initialize a variable of type 'LineVertex*' (aka '_Line Vertex*) with an rvalue of type 'void*'
This is the line of code:
LineVertex *vertices = calloc(sizeof(LineVertex*), numberOfVertices);
This worked until I switched my class from .m to .mm and now it's throwing me that error and I don't know how to fix it. I am using Xcode 5 and the latest version of Cocos2D. I read that it might have something to do with casting but I honestly don't know how to do that, I couldn't get it to work correctly. Thank you so much in advance!
It should be like this.
LineVertex *vertices = static_cast<LineVertex *>(calloc(sizeof(LineVertex*), numberOfVertices));
For further information, please take a look at the FAQ.
Bjarne Stroustrup's C++ Style and Technique FAQ: Why must I use a cast to convert from void*?
Related
My code compiles well with 'make.' However, when I attempt to do the same with Xcode, the code shows the following error:
"Invalid operands to binary expression ('const value_type' (aka 'const Vertex') and 'const value_type' (aka 'const Vertex'))"
I would be grateful if someone please point me towards a solution. I am currently using OSX 10.10.4 and Xcode 6.3.2. The corresponding screenshot is kept here:
The error message seems clear. You can't use == to compare these two objects. Research and discover another way to compare those object or amend the == operator so that it accepts the types you'd like to compare.
A search of similar error messages on SO yields a number of good answers including:
Invalid operands to binary expression
Just tried a simple solution. Deleted Xcode 6.3.2 and installed back Xcode 6.1.1. Everything now works fine. I have no idea though what has really happened here.
I was using ADT v22.6.2. There is no problem for my render script code. After I upgrade to ADT 23.0.2, I got some compilation errors.
error: Compute kernel root() cannot have non-pointer parameters besides 'x' and 'y'. Parameter 'ycoord' is of type: 'uint32_t' imagealign.rs
Does anybody have an idea how to fix it? Thanks.
Newer version of the RS toolchain enforce the names of the coordinates be "x" or "y". The reason for this is to disambiguate with other possible future params. To fix this simply rename 'ycoord' to 'y'.
It seems that antlr-3.5.1-complete.jar and antlr-3.5.1-complete-no-st3.jar generates
code targeting C runtime that has a lot of the "_empty" identifier in the DFA that
is not defined anywhere.
antlr-3.4 generates the code using dfa31_T_empty which should be the correct id.
I could probably fix this by defining _empty as NULL but that's a hack.
Is there any antlr-3.5.2 or so available that fixes this error?
Cheers,
Adrian Pop/
I have encountered this error too. The simplest and cleanest solution indeed seems to be to add this to your grammar:
#header
{
#define _empty NULL
}
The other solution is to add this define to your compiler macro list (/D _empty=null seems to work in both GCC and MSVC).
I wrote this little demo code with libusb:
require 'libusb'
usb = LIBUSB::Context.new
device = usb.devices(:idVendor => 2362).first
puts device.all_input_usages
But somehow I don't get the error:
undefined method `all_input_usages' for #<LIBUSB::Device:0x2091fa8>
What did I do wrong?
You should step away from that demo code, because it is hopelessly outdated and the API has radically changed since.
You can see all available methods in IRB when you type device.methods - Object.new.methods, it's a trick i often use when i want to explore what an object has to offer. Maybe this will help you find the method you are looking for.
I guess that the idVendor should be written in hexadecimal spelling, so maybe device = usb.devices(:idVendor => 0x2362).first will work.
> I have visual studio c++ express and a NVIDIA GeForce 7900 GS. I'm using glew to get at the openGL extensions. Calling glGenBuffers crashes as its a NULL pointer tho. I have an open GL context before I make the call ( wglGetCurrentContext() != NULL ). I'm calling glewInit() before the call. glewGetString( GLEW_VERSION ) is returning GLEW_VERSION_1_5. What am I doing wrong ? Is the card too old ? Is it the driver ?
Remember to make a glewInit() call in your code so that you get valid pointers to GL functions.
Hope it helps.
Without seeing your code it would be difficult to tell, but what you are attempting to do seems like it could be helped a lot by using GLee. It is designed to load all current extensions and you have the ability to check what is supported, e.g. :
#include <gl\GLee.h> // (no need to link to gl.h)
...
if (GLEE_ARB_multitexture) //is multitexture support available?
{
glMultiTexCoord2fARB(...); //safe to use multitexture
}
else
{
//fallback
}
The above was shamelessly copy/pasted from the GLee site, but it displays the functionality I'm trying to showcase.
You need to call glewInit() post having a valid context. And that would be, in the world of glew, after you've called glfwMakeContextCurrent(myWindow);
I have actually run into this problem with GLEW. For me, it was nullifying the function pointer for glGenerateMipmap. I fixed it by simply restoring the pointer to the appropriate function. This is my example in Linux:
glGenerateMipmap = (void(*)(GLenum))
glXGetProcAddressARB((GLubyte*)"glGenerateMipmap");
There is a WGL equivalent for glXGetProcAddress; I just don't remember the name off the top of my head. Try manually restoring the functions using this method. If you come across many functions that are null, something is definitely wrong in your setup process. The only other functions I recall having to restore were glGenVertexArrays, glBindVertexArray, and glDeleteVertexArrays. If your glGenBuffers is null, odds are that glBindBuffer and glDeleteBuffers are null as well. :(
Test if the desired extension is actually supported by checking the string returned by glGetString(GL_EXTENSIONS); if it's not there you know what's causing your problems.