MakerGram Logo

    MakerGram

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags
    • Users
    • Groups

    Problems with using struct and enum in another tab

    Arduino
    2
    3
    415
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      FlorianB last edited by

      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

      1 Reply Last reply Reply Quote 1
      • F
        FlorianB last edited by

        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

        1 Reply Last reply Reply Quote 1
        • salmanfaris
          salmanfaris last edited by

          happy to hear that 🙂 👍

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          Recent Posts

          • O

            The Yankees might attain a necessary pitching reinforcement towards commence the calendar year with straight rotator cuff tendinitis, Clarke Schmidt intended his instant rehab start out for Double-A Somerset upon April 10, tossing 4 scoreless innings with 4 strikeouts, no walks and 4 hits permitted. He threw 61 pitches, 45 of them getting me, it simply above turning out to be back again within that video game come to feel and the aggressive spirit, Schmidt explained soon after his outing. pitching a very little in another way inside of choice counts, blending and matching and using artistic out was a single of the 3 projected Yankees starters who ended up befelled through destruction ahead of the month to month time begun. Yankees ace Gerrit Cole underwent period-finishing Tommy John surgical procedures inside mid-March, though reigning AL Newbie of the 12 months champion Luis Gil is sidelined with a specifically lat anxiety. Schmidt afterwards connected them upon the hurt record Though he felt his shoulder bark and was scratched in opposition to his March 16 Grapefruit League start was Clarke's instant rehab begin with the Patriots as soon as he struck out 7 earlier mentioned 3 1/3 scoreless innings upon 52 pitches for Somerset upon April 5 https://www.nyyankeesprostore.com/Jacoby_Ellsbury_Jersey-28
            . Yankees supervisor Aaron Boone mentioned upon April 5 that they predicted just before this getting Schmidt's ultimate commence rejoining the significant league rotation upon April 15 or 16 vs. Kansas Metropolis. Schmidt reiterated just after his minute start out that the expect was in the direction of return this foreseeable future 7 experienced a 2 https://www.nyyankeesprostore.com/Alex_Rodriguez_Jersey-9
            . 85 Technology with 93 strikeouts inside 85 1/3 innings for the Yankees closing period. The specifically-hander neglected 3 1/2 weeks inside 2024 thanks toward a straight lat anxiety prior to returning inside early September and creating 3 begins inside the playoffs, which includes Activity 3 of the Entire world Max Fried, Carlos Rodn and Marcus Stroman in all probability penciled into the rotation for the Yanks, Schmidt's return will stress a alternative between Carlos Carrasco and Will Warren, the latter of whom is made up of Tiny League Programs becoming.

            https://www.nyyankeesprostore.com

            • read more
          • @codelery Awesome. That's great news. Kudos to @rafitc99 . 🙌

            @codelery Please keep us updated about your project, looking forward to seeing it in action 🤩

            • read more
          • C

            @rafitc99 I changed the buffer and that solved the problem. Thanks a lot for coming to my rescue.

            • read more
          • C

            @salmanfaris I did change the buffer size and everything is working perfectly. Thanks coming to my rescue.

            • read more
          • @codelery said in Help needed: Arduino Wireless Notice Board project:

            I am using the hardware serial (pin 0 and 1 on Arduino Uno)

            As @rafitc99 mentioned, you need to expand the Serila buffer, in the hardware serial also the Arduino board package implements a 64-byte ring buffer for send and receive on the hardware serial messages. So you need to change that to 256 as per your message length.

            • read more
          By MakerGram | A XiStart Initiative | Built with ♥ NodeBB
          Copyright © 2023 MakerGram, All rights reserved.
          Privacy Policy | Terms & Conditions | Disclaimer | Code of Conduct