Ask coding questions

← Back to all posts
Can I change compiler switches?
Jack_AdrianAdr1

Is it possible to modify/add to the compiler switches for C++? Or are they fixed on this platform?

Voters
a5rocks
Jack_AdrianAdr1
AllAwesome497
Comments
hotnewtop
a5rocks

Yes! right-click repl, click "open command palette", type "shell", press enter, type "clang++ main.cpp -compiler_options_here -o main", press enter, then type "./main".

UPDATE: It works for me :) (though I don't actually know if the compiler options actually change anything, but they should)

Also, you can upvote this feature request so maybe repl will add a more intuitive way : https://repl.it/feedback/p/visually-change-compiler-switches

Jack_AdrianAdr1

@a5rocks

right-click repl

Where? The places that I right clicked gave me the default chrome context menu. A screenshot would be useful.

Thanks.

JA

a5rocks

@Jack_AdrianAdr1 oof. have you tried ctrl+shift+p?

ctrl+shift+p just doesn't work on repl.it on Firefox, the browser I use.

Jack_AdrianAdr1

@a5rocks good, that worked. Well, there was no "open command palette" it was actually "Open Shell", but whatever.

Not a good UI design, as that menu isn't very discoverable. Now that I know that it's there, definitely better though. Still couldn't find that context menu you were talking about.

a5rocks
PedroSerra

if you place a "Makefile" with the compilation rules it calls make when you press play. There are plenty of Makefile examples out there but yet here's an example where I have included the command to run the program after compilation.

CC=gcc
CFLAGS=-Wall -Wpedantic -Wextra -std=c99 -Wvla
LFLAGS=-lncurses
SOURCE=$(wildcard *.c)
TARGET=main

all:
$(CC) $(CFLAGS) -o $(TARGET) $(SOURCE) $(LFLAGS)
./$(TARGET)

Terri_MarieMari

I found it and opened it but can't type in it. Pretty frustrating