Problems with using struct and enum in another tab



  • Hi I am using multiple tabs to make a big project more readable. Now i wanted one tab just to define structs and enums and get them out of the way.

    The problem is that e.g. in tab#2 i can't use these data structures because they were "not declared in this scope". So I included the tabs using something like
    #include "./tabWithEnums"

    This works fine until I want to use the same structs in a third tab. If I don't include the defining tab, then I get the upper error. If I include the defining tab in tab#3 then I get the error "redeclaration of ...".

    Running out of ideas, I put the structs and enums in the main tab - same result.

    May last idea was to define for example an enum with ON/OFF as values in every tab where I need them. Then I get the error "redeclaration" too.
    So i can't declare it twice because the IDE complains about double declaration but at the same time I can't use the correct declaration in the other tab. I am getting mad here.

    I reduced the example code to this:

    TAB1:

    #include "./tab2.h"
    
     enum {
      off,
      on
     };
     
     void setup() {
      Serial.begin(9600);
      Serial.println();
    }
    
    void loop() {
      something();
      delay(10000);
    }
    

    TAB2:

    void something () {
      Serial.println (on);
    }
    

    result:
    exit status 1
    'on' was not declared in this scope

    please help. I lost several hours on this and I don't want to go back and put all code in one TAB. Btw. I know how to use variables over various tabs (using "extern") and methods (by declaring them from the calling tab) but both doesn't help me. Just so you know that I really tried.

    thank you



  • I found the solution: if I #include all tabs in the main tab in the right order and the one with the structs is alphabetically before the others then it will work



  • happy to hear that ๐Ÿ™‚ ๐Ÿ‘


Log in to reply
 

Recent Posts

  • P

    @Anudeep Thanks a lot m8, I actually made a very silly mistake of including the https:// while entering FIREBASE_HOST, where I must have entered the Domain name alone and removed the https:// extension.

    Thanks again for replying that quick. Cheers.

    read more
  • A

    Hello @Palani, In the Firebase, there are two types of storage,

    Cloud Firestore (Very recent one & NoSQL database) Realtime Database (To which we upload the data using NodeMCU)

    In the Arduino Code, you can see that there is a variable named FIREBASE_AUTH.

    This variable should be assigned to the Database secret. This you can find in Project Settings -> Service accounts -> Database Secrets.

    My mistake is, i have mistakenly assigned thay to Web API key. This is found at Project Settings -> General.

    The error can also occur when u don't initialise a proper realtime database in Firebase. (This is not my case).

    read more
  • P

    @Anudeep Hello Anudeep could you please help me out by elaborating the fix to get rid of that error?
    Thanks in advance.

    read more
  • At Adobe, weโ€™re focused on bringing together the most intelligent, driven, diverse set of individuals and give them the freedom to nurture their intellectual curiosity. We provide them with the necessary resources and support to shape their ideas into tangible results.
    Through the Adobe India Women-in-Technology Scholarship, we are striving towards creating gender equality in science, technology and engineering domains by encouraging women to showcase their excellence in computing and technology and become future leaders and role models in the field.

    ๐—›๐—ผ๐˜„ ๐˜๐—ผ ๐—ฎ๐—ฝ๐—ฝ๐—น๐˜†?

    Applications must be submitted through their dedicated application portal which opens on August 20th, 2020 and will close on September 20th, 2020, 5 pm India time.

    ๐—”๐—ฝ๐—ฝ๐—น๐—ถ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ฑ๐—ฒ๐—ฎ๐—ฑ๐—น๐—ถ๐—ป๐—ฒ:

    Application deadline: September 20th, 2020, 5 pm India time.

    Visit:- https://research.adobe.com/adobe-india-women-in-technology-scholarship/

    read more
  • @kowshik1729 If you are using an external high-speed switch, there is only one one clock generator for both wifi and BLE and the high-speed switch you mentioned is Ultra-Wideband (UWB) 3โ€“8 GHz from its datasheet

    b2da6871-9110-40f1-8ff0-d8313547a17a-image.png

    you also check this solution that I shared in the previous post.

    @salmanfaris said in BT and WiFi Dual Core simultaneous operation using ESP32?:

    There is a special option called โ€œSoftware controls WiFi/ Bluetooth coexistenceโ€ it can control the ESP32's Bluetooth and Wi-Fi coexistence using software, more details: https://www.espressif.com/sites/default/files/documentation/ESP32_FAQs__EN.pdf

    read more