Function-like Macros | C Programming Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 มิ.ย. 2024
  • How to use function-like macros in C, also known as parameterized macros or macros with arguments. Source code: github.com/portfoliocourses/c.... Check out www.portfoliocourses.com to build a portfolio that will impress employers!

ความคิดเห็น • 50

  • @DaiMoscv
    @DaiMoscv ปีที่แล้ว +29

    Your videos on C are the best! I'm guessing only reason people aren't watching your videos because they're usually new to the language and just stick with the shortest and simplest videos out there. But I'm really glad that you're also teaching not so popular topics.

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว +2

      Thank you for the positive feedback Bilguun, I appreciate it. :-) The channel is a bit new and the growth has been good lately, so hopefully it keeps up and more people keep finding the content.

    • @dzentsetsu5607
      @dzentsetsu5607 ปีที่แล้ว +2

      @@PortfolioCourses They will, you are the best tutor of C in my opinion and kinda in programming in general. I also have a suggestion for vid. Basically new programmers (including myself) are unware how process is created and how os automatically behind the scenes (I am guessing at this point) assigns such things like stdin stdout stderr for a process. Such things are extremely hard to google, but every low level programmer needs to know about it.

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว +2

      @@dzentsetsu5607 Thank you for the support and the video topic suggestion! 🙂 I've thought about covering some shell scripting one day, and that would touch on some of these ideas.

    • @beulahagiande7087
      @beulahagiande7087 9 หลายเดือนก่อน

      I totally agree!

  • @andredcavalcante
    @andredcavalcante หลายเดือนก่อน

    I teach classes about C in my University. Your videos are part of this. Very good content about C. Congratulations.

  • @user-yu9zl1vq2m
    @user-yu9zl1vq2m 6 หลายเดือนก่อน +3

    finally found the perfect tutor for learning c programming :)

  • @AlameenAdeyemi
    @AlameenAdeyemi 4 หลายเดือนก่อน +1

    Concise and straight to the point, thank you sir

  • @itakagastonkitambala3918
    @itakagastonkitambala3918 ปีที่แล้ว +5

    Wow, this is by far the best C programming playlist I have come across on TH-cam. Your teaching style is on point and the explanations are clear. Please keep the good content coming. I am happy that I found this channel. I write code for embedded systems, and we use macros a lot, this was so helpful. Thank you.

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว

      Thank you very much for the kind feedback Itaka, I'm really glad to hear that you enjoy the channel and teaching style. :-)

  • @luisvelasquez650
    @luisvelasquez650 8 หลายเดือนก่อน

    Quality content! Your explanation is very clear, thanks for sharing your knowledge!

  • @edidiongedemeka2096
    @edidiongedemeka2096 ปีที่แล้ว +1

    Thank you for this video man!! really straight to the point and just all around good stuff!

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว +1

      You're welcome Edidiong, I'm glad that you enjoyed it! :-)

  • @abdlelya4239
    @abdlelya4239 ปีที่แล้ว

    Thank you for these great vids 👏🏻👏🏻🙏🙏🙏the deeper i get into c the more i understand how valuable these vids truly are

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว

      You're very welcome Abdl, I'm glad you're enjoying the videos! :-)

  • @Architector120
    @Architector120 2 ปีที่แล้ว +7

    This is probably the best tutorial on C macros on TH-cam! Thank you for the great lesson!
    Also could you make a video on how to make makefiles + explain some basic compiler parameters.

    • @PortfolioCourses
      @PortfolioCourses  2 ปีที่แล้ว +4

      Thanks! :-) And yes, I'm hoping to make an "introduction to makefiles" video some day.

  • @leiyplane2011
    @leiyplane2011 9 หลายเดือนก่อน

    Excellent explanation! Thank you Sir.

  • @arthur_p_dent4282
    @arthur_p_dent4282 ปีที่แล้ว +1

    Macros are so much fun. Good call on using the brackets. I actually just wrote my own min max macros and did not enclose them in brackets.

  • @omogwuakor7571
    @omogwuakor7571 4 หลายเดือนก่อน

    Thank you so much sir for tge time you put into making these nice videos...🎉

  • @zainalishammat2866
    @zainalishammat2866 ปีที่แล้ว +1

    the best so far ever education in C. Thank you very mush :)

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว

      You're very welcome Zain, and thank you for the positive feedback! :-)

  • @humongous1234
    @humongous1234 8 หลายเดือนก่อน

    Sir,you are great.

  • @DC-of7lp
    @DC-of7lp ปีที่แล้ว +1

    best C programming channel on youtube:)

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว

      Thank you for the very positive feedback, it's much appreciated! :-)

  • @michaelpatterson1096
    @michaelpatterson1096 ปีที่แล้ว +2

    Thank you. I am reading a book and was lost. This helps a lot.

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว +1

      You're welcome Michael! :-) I'm really glad to hear this was helpful for you, thanks for sharing that positive feedback.

  • @qsmfoui
    @qsmfoui 4 หลายเดือนก่อน

    when you define output you attach a semicolon to the end which will result in an empty expression if you put another one at the end of your code

  • @bofa-zi4fj
    @bofa-zi4fj 11 หลายเดือนก่อน +1

    I understand why you don’t want to add a “return” @ 17:17. For this example, the return will cause main() to finish. However, I’m a bit confused on why “max_int” sees the final line of the macro @ 18:18? Since the text is getting replaced, why doesn’t “max_int” see “int current_max = array[0];”? I.e., why does it not evaluate to “int max_int = int current_max = array[0];” with the rest of the macro following?

  • @rakurame6990
    @rakurame6990 2 ปีที่แล้ว +1

    If my understanding is correct,
    Function like macros are widely used in AUTOSAR architecture to make abstraction between the layers.
    (Automotive Domain)

    • @PortfolioCourses
      @PortfolioCourses  2 ปีที่แล้ว

      That sounds like a good usage of function-like macros. :-) I've seen macros used a lot to address compatibility and portability issues in general.

    • @muneerbasha1958
      @muneerbasha1958 ปีที่แล้ว

      Yes we use macros in Autosar

  • @simonapopa9397
    @simonapopa9397 2 ปีที่แล้ว +1

    super!

  • @TechnoSan09
    @TechnoSan09 ปีที่แล้ว +2

    doing great job
    but ur channel is underrated

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว +1

      Thank you very much for the kind words! :-)

    • @TechnoSan09
      @TechnoSan09 ปีที่แล้ว

      @@PortfolioCourses ur welcome😇

    • @TechnoSan09
      @TechnoSan09 ปีที่แล้ว

      @@PortfolioCourses i subbed u!

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว

      Awesome, welcome aboard! :-)

  • @gammyhorse
    @gammyhorse ปีที่แล้ว +1

    Unfortunately I can't make it run in Visual Studio. The compiler freaks out with the last macro, giving me errors that they don't make any sense. Like syntax error, unrecognized token, it does not recognize the if statement inside the macro. I promise, I don't have any of these. My code looks absolutely like yours. It's so frustrating, and I'm looking for another IDE for c/c++ on windows. I think I'll try CodeBlocks, but If you have in mind something better from your experience, please give me your suggestion. Anyway, thank you very much in advance.

    • @PortfolioCourses
      @PortfolioCourses  ปีที่แล้ว +2

      I think using gcc would be best for compatibility. I've heard of some folks having success getting gcc on Windows with this: www.mingw-w64.org/. :-) You could even use an in-browser IDE if you just want to learn, they all use gcc "under the hood" and if it's only for learning the language it's fine.

    • @ILightWas
      @ILightWas ปีที่แล้ว +2

      The reason for your errors is that gcc has a feature called Statement Expressions. In contrast msvc doesn't. The issue is that you can't assign a block of code to a variable, the find_max macro generates invalid C code, like int foo = ({ .... current_max; });

    • @gammyhorse
      @gammyhorse ปีที่แล้ว +1

      @@ILightWas Thanks

  • @ALGCoders
    @ALGCoders 2 ปีที่แล้ว

    cool

  • @programacionpse3520
    @programacionpse3520 ปีที่แล้ว +1

    You Cool ! MAN