Program could compile in another tab arduino IDE(a function-definition is not allowed here before '{' token)

hi there.,,i dont know what my mistake here,,i try this program in another place its work fine.but here when i try this in another arduino tab,it couldnt compilig.
this is an error:

Compiling sketch...

"C:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\1.22.0-80-g6c4433a-5.2.0/bin/xtensa-esp32-elf-g++" -DESP_PLATFORM "-DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\"" -DHAVE_CONFIG_H "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/config" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/app_trace" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/app_update" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/asio" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/bootloader_support" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/bt" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/coap" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/console" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/driver" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/esp-tls" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/esp32" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/esp_adc_cal" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/esp_event" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/esp_http_client" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/esp_http_server" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/esp_https_ota" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/esp_ringbuf" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/ethernet" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/expat" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/fatfs" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/freemodbus" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/freertos" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/heap" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/idf_test" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/jsmn" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/json" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/libsodium" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/log" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/lwip" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/mbedtls" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/mdns" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/micro-ecc" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/mqtt" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/newlib" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/nghttp" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/nvs_flash" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/openssl" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/protobuf-c" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/protocomm" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/pthread" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/sdmmc" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/smartconfig_ack" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/soc" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/spi_flash" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/spiffs" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/tcp_transport" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/tcpip_adapter" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/ulp" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/vfs" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/wear_levelling" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/wifi_provisioning" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/wpa_supplicant" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/xtensa-debug-module" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/esp-face" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/esp32-camera" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/esp-face" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3/tools/sdk/include/fb_gfx" -std=gnu++11 -fno-exceptions -Os -g3 -Wpointer-arith -fexceptions -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -w -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -fno-rtti -MMD -c -DF_CPU=240000000L -DARDUINO=10815 -DARDUINO_ESP32_DEV -DARDUINO_ARCH_ESP32 "-DARDUINO_BOARD=\"ESP32_DEV\"" "-DARDUINO_VARIANT=\"esp32\"" -DESP32 -DCORE_DEBUG_LEVEL=0 "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3\\cores\\esp32" "-IC:\\Users\\ridho\\Documents\\ArduinoData\\packages\\esp32\\hardware\\esp32\\1.0.3-rc3\\variants\\esp32" "C:\\Users\\ridho\\AppData\\Local\\Temp\\arduino_build_765436\\sketch\\menu_baru.ino.cpp" -o "C:\\Users\\ridho\\AppData\\Local\\Temp\\arduino_build_765436\\sketch\\menu_baru.ino.cpp.o"

C:\Users\ridho\Documents\Arduino\menu_baru\menu_baru.ino: In function 'void setup()':

menu_baru:10:12: error: a function-definition is not allowed here before '{' token

 void loop(){

            ^

rectangle:30:1: error: expected '}' at end of input

 }

 ^

exit status 1

a function-definition is not allowed here before '{' token

this is my code:

//programed: megantara
bool ledState = true; // state variable for the buzzer
unsigned long interval=500; // the time we need to wait
unsigned long previousMillis=0; // millis() returns an unsigned long.

void setup(){
  pinMode(25, OUTPUT);
 digitalWrite(25, ledState);

void loop(){
 unsigned long currentMillis = millis(); // grab current time
  
 // check if "interval" time has passed (1000 milliseconds)
 if ((unsigned long)(currentMillis - previousMillis) >= interval) {
   
   ledState = false; // "toggles" the state
   digitalWrite(25, ledState); // sets the LED based on ledState
   // save the "current" time
   previousMillis = millis();
 } 
}

this is error when appears on display:

and this is when i try compile in another arduino tab it works. im very confuse now.


so anyone know what is my mistakes here??

thanks
azhar

A very helpful troubleshooting tool is the Auto Format feature (Tools > Auto Format in the Arduino IDE or Ctrl+B in the Arduino Web Editor). If you do an Auto Format and then compare the resulting indentation to your intended program structure, it will quickly point you to where there is a missing or extra brace. I think the cause of the error will be clear once you do that.

Another useful feature of the Arduino IDE/Arduino Web Editor is that when you place the cursor next to one bracket, it puts a box around the matching bracket. In the Arduino IDE, if the cursor is next to the closing bracket and the opening bracket is off the screen then it will show the opening bracket line in a tool tip after a short delay.

Hi @ridhoazhar313
In void setup(), before the void loop() need a "}"

RV mineirin

oh my Allah!!!!.....im sorry everybody!!!...i dont see..because im so tired now...ive work from morning until now,,,may be i will take a rest and java...thanks a lot !!!! :sob: :sob: :sob:

You're welcome. I'm glad if I was able to be of assistance. Enjoy!
Per

may Allah give u hidayah!!! :persevere: :persevere: :sob: :sob: