We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2564

Summary: SDL_PushEvent return success value(1) when actual fault
Product: SDL Reporter: Dmitry <dmitriykuchevskiy>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.1   
Hardware: x86_64   
OS: Windows 7   

Description Dmitry 2014-05-29 20:50:20 UTC
This code example demonstrate bug:

#include <SDL.h>
#include <iostream>

int main(int argc, char** argv)
{
    SDL_Init(SDL_INIT_EVERYTHING);
    SDL_UserEvent myEvent;
    myEvent.code = 0;
    SDL_Event event;
    SDL_PushEvent(reinterpret_cast<SDL_Event*>(&myEvent));
    SDL_PollEvent(&event);
    if (event.user.code == 0)
        std::cout << "OK";
    return 0;
}

"OK" message does not appear because missing assignment
Event.type = SDL_USEREVENT; (without this Event.type can have any value)
But nevertheless SDL_PushEvent return success value (1).

Probably this is my misunderstanding, but I think that this is a bug.
Comment 1 Sam Lantinga 2014-06-22 17:00:41 UTC
It works for me here, you're just missing a newline:
std::cout << "OK" << std::endl;
Comment 2 Sam Lantinga 2014-06-22 17:01:53 UTC
Also, you need to specify the event type. Unlike C++, in C there are no default constructors for structures so you need to explicitly initialize every field in them.