"void value not ignored as it ought to be" error?

This is a discussion on "void value not ignored as it ought to be" error? within the C++ Programming forums, part of the General Programming Boards category; can anyone help me with this? i've been trying for 2 hours to fix this... I don't know why I'm ...

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    30

    Red face "void value not ignored as it ought to be" error?

    can anyone help me with this? i've been trying for 2 hours to fix this... I don't know why I'm getting this?

    Instantiation:

    Code:
    	memento::VertexBuffer<uint> buff;
    	buff = memento::VertexBuffer<uint>();
    Code:
    #ifndef VERTEXBUFFERS_H
    #define VERTEXBUFFERS_H
    
    #include "Alias.h"
    #include "GLlibs.h"
    
    namespace memento{
    
    template<typename NumType>class VertexBuffer{
    	uint vertexbuffer_buffer;
    	ulong vertexbuffer_drawtype;
    
    public:
    
    	VertexBuffer():vertexbuffer_buffer(glGenBuffers(1, &vertexbuffer_buffer)),
    	vertexbuffer_drawtype(GL_STATIC_DRAW){}
    
    	VertexBuffer(NumType* bufferdata, ubyte drawtype = GL_STATIC_DRAW):
    		vertexbuffer_buffer(glGenBuffers(1, &vertexbuffer_buffer)),
    		vertexbuffer_drawtype(drawtype){
    
    		setBuffer(bufferdata);
    	}
    
    	~VertexBuffer(){
    		glDeleteBuffers(1, &vertexbuffer_buffer);
    	}
    
    	void setBuffer(NumType* bufferdata){
    		bind();
    		glBufferData(GL_ARRAY_BUFFER, sizeof(bufferdata), bufferdata, vertexbuffer_drawtype);
    		unbind();
    	}
    
    	void setDrawType(ulong drawtype){vertexbuffer_drawtype = drawtype;}
    
    	uint const& getBuffer(){return (vertexbuffer_buffer);}
    	ulong const& getDrawType(){return (vertexbuffer_drawtype);}
    
    	void bind(){
    		glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer_buffer);
    	}
    
    	static void unbind(){
    		glBindBuffer(GL_ARRAY_BUFFER, nil);
    	}
    };
    
    };
    
    #endif

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    2,915
    Please post the complete error message. These messages have important information to aid in locating and fixing the errors.


    Jim

  3. #3
    Registered User
    Join Date
    May 2011
    Posts
    30
    Quote Originally Posted by jimblumberg View Post
    Please post the complete error message. These messages have important information to aid in locating and fixing the errors.


    Jim
    "..\src\VertexBuffers.h: In instantiation of 'memento::VertexBuffer<NumType>::VertexBuffer() [with NumType = unsigned int]':
    ..\src\memento_lib.cpp:31:30: required from here
    ..\src\VertexBuffers.h:16:38: error: void value not ignored as it ought to be"

    In VertexBuffer's constructor (default and regular).

  4. #4
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,438
    you are probably trying to use return value in a function that you have declared void return type
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  5. #5
    Registered User
    Join Date
    May 2011
    Posts
    30
    Quote Originally Posted by rogster001 View Post
    you are probably trying to use return value in a function that you have declared void return type
    Where? it highlights the constructor, which makes no sense...

  6. #6
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,438
    in your source files somewhere?

    Code:
    void getval()
    {
        return 10;
    }
    
    int main()
    {
        int x = getval();
    }
    that will give you the same error

    You may be calling your functions in source and saying i = foo(); or you may have a return statement in the function definition, if you are aware of these type of mistakes and its not that then i dont know - but also remember another problem can cascade down and cause the compiler to output many errors that do not " really " exist.
    Last edited by rogster001; 09-11-2012 at 02:12 PM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  7. #7
    Registered User
    Join Date
    May 2011
    Posts
    30
    Code:
    memento::VertexBuffer<uint> buff;buff = memento::VertexBuffer<uint>();
    this is the only bit where the class in question is utilized...

  8. #8
    Registered User
    Join Date
    Oct 2006
    Posts
    2,578
    it appears you're using visual C++. what version are you using?

    edit:

    strike that, I guess it looks more like gcc. in any case, my question still stands.

    type the following command in a console window:

    Code:
    g++ --version
    and tell us how it responds

  9. #9
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    glGenBuffers has a void return value:
    Code:
        VertexBuffer():vertexbuffer_buffer(glGenBuffers(1, &vertexbuffer_buffer)),     vertexbuffer_drawtype(GL_STATIC_DRAW){}
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  10. #10
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,438
    i think is defo gcc - am wondering if there is a problem with setbuffer, beyond me really tho - i would consider the gl calls - darn already got posted! - well spotted
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  11. #11
    Registered User
    Join Date
    May 2011
    Posts
    30
    I thought genbuffers returned an int for some reason Thanks guys! (Oh, and I'm using g++ in Eclipse Juno.)

  12. #12
    Registered User
    Join Date
    Oct 2006
    Posts
    2,578
    Quote Originally Posted by Shokwav View Post
    I'm using g++ in Eclipse Juno.
    that doesn't tell me what version of g++ it is. it's a moot point now, but the only way to know the compiler version (g++ is a compiler, eclipse is an IDE) is to run the command I gave you previously.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. "invalid use of void expression" error
    By smith283 in forum C Programming
    Replies: 19
    Last Post: 09-04-2012, 10:10 AM
  2. the operator "="error in class "String"
    By boyhailong in forum C++ Programming
    Replies: 9
    Last Post: 07-27-2011, 09:39 PM
  3. "Segment Violation" error, fopen("r+")
    By jiboso in forum C Programming
    Replies: 1
    Last Post: 03-10-2011, 09:57 AM
  4. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 08:25 AM
  5. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 07:59 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21