Screen is black only in Mac environment

I wrote some code with SDL, but it isn’t working correctly on Macs. There is supposed to be a white rectangle onscreen, and this occurs in Windows and Ubuntu environments, but not on Macs. In a Mac environment, there’s only a black screen. I’ve tried both installing SDL using a package manager and by codesigning the framework, but that hasn’t remedied the problem. How I compiled my file is below:

g++ example.cpp -lSDL2

g++ example.cpp -I/Library/Frameworks/SDL2.framework/Headers -F/Library/Frameworks -framework SDL2

The problem may also be with my code itself. The code is below:

#include <SDL2/SDL.h>
#include
#include <stdio.h>
#include <assert.h>

const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
const int PLAYER_WIDTH = 20;
const int PLAYER_HEIGHT = 20;
SDL_Window* w = NULL;
SDL_Surface* s = NULL;
SDL_Renderer* r = NULL;
SDL_Rect BG = {0,0,SCREEN_WIDTH,SCREEN_HEIGHT};

bool init() {

if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
	printf("Couldn't initialize. error: %s\n", SDL_GetError() );
	return false;
} else {

	w = SDL_CreateWindow("test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);


	if(w == NULL) {
		printf("Couldn't make window. error:%s\n", SDL_GetError() );
		return false;
	} else {
		s = SDL_GetWindowSurface(w);
		r = SDL_CreateRenderer(w,-1,SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
		SDL_SetRenderDrawColor(r,0,0,0,0);
		return true;
	}

}

}

void close() {
SDL_FreeSurface(s);
SDL_DestroyWindow(w);
SDL_DestroyRenderer®;
SDL_Quit();

}

class Player {

private:
	int x;
	int y;
	int xvel;
	int yvel;
	int acceleration;
	


public:

	bool landed;
	SDL_Rect collider;

	Player() {
		x = 0;
		y = SCREEN_HEIGHT - PLAYER_HEIGHT;
		xvel = 0;
		yvel = 0;
		acceleration = -1;
		collider.x = x;
		collider.y = y;
		collider.w = PLAYER_WIDTH;
		collider.h = PLAYER_HEIGHT;			
		landed = true;
	}

	int getx() {
		return x;
	}

	int gety() {
		return y;
	}

	void setx(int num) {
		x = num;
	}

	void sety(int num) {
		y = num;
	}

	void setyvel(int num) {
		yvel += num;
	}

	void setxvel(int num) {
		xvel += num;
	}

	void move() {
		x += xvel;

		if( (y + PLAYER_HEIGHT) > SCREEN_HEIGHT) {
			
			y = SCREEN_HEIGHT - PLAYER_HEIGHT;
			yvel = 0;
			landed = true;

		} else {
			if(landed != true) { 
				y += yvel;
				yvel = yvel - acceleration;
			}
			
		}

		
		collider.x = x;
		collider.y = y;
	}

	void render() {
		SDL_SetRenderDrawColor(r,255,255,255,255);
		SDL_RenderFillRect(r,&collider);
		SDL_SetRenderDrawColor(r,0,0,0,255);
	}

};

int main(int argc, char *argv[]) {

bool quit = false;
SDL_Event e; //event for event polling
Player p;
int count = 0;

if(init() == false) {

	printf("Init failed: %s\n", SDL_GetError());

} else {
	while(quit == false ) {
		while( SDL_PollEvent(&e) != 0) {

			if(e.type == SDL_QUIT) {
				quit = true;
			}


			
			if(e.type == SDL_KEYDOWN) {

				switch(e.key.keysym.sym) {

					case SDLK_LEFT: if(e.key.repeat == 0) { p.setxvel(-10); }
					break;

					case SDLK_RIGHT: if(e.key.repeat == 0) { p.setxvel(10); }
					break;

					case SDLK_UP:

					if(count < 5) {
					    p.setyvel(-3);
					    ++count;
					    } 
						p.landed = false;
					
					break;

				}

			}

			

			if(e.type == SDL_KEYUP && e.key.repeat == 0) {

				switch(e.key.keysym.sym) {

					case SDLK_LEFT: p.setxvel(10);
					break;

					case SDLK_RIGHT: p.setxvel(-10);
					break;

					case SDLK_UP: count = 0;
					break;

				}

			}

			

		}
		
		SDL_RenderClear(r);
		SDL_RenderFillRect(r,&BG);
		p.move();
		p.render();
		

		SDL_RenderPresent(r);

		assert(&r!=NULL);
		assert(&p!=NULL);
		assert(&(p.collider)!=NULL);
		assert(&s!=NULL);

	}
}
close();

}