Back to Basics: The Structure of a Program - Bob Steagall - CppCon 2020

Поделиться
HTML-код
  • Опубликовано: 28 янв 2025

Комментарии • 29

  • @wagsman9999
    @wagsman9999 3 года назад +31

    As a newbie to c++ I’m finding these “back to basics” lectures very informative

    • @CppCon
      @CppCon  3 года назад +7

      Great to hear!

  • @carterthaxton
    @carterthaxton 4 года назад +20

    Thanks to Bob Steagall for this. At 26:20, there's an example that shows how large the intermediate translation unit would be for separate main.cpp and hello.cpp files. The size of main.i would be considerably smaller by not #including in hello.h, and only in hello.cpp. I think it's pretty important to not include headers from other headers unless the declarations are necessary for the interface. In this case, is only needed for the implementation of hello.cpp, and not the interface exposed by hello.h. This example could have been used to clarify this important difference.

    • @davidfong
      @davidfong 2 года назад +4

      That's a good point. As an addition to that, if the header needs to define a function that takes a stream reference, the header can #include , which just has forward declarations of the things defined in .

    • @tourdesource
      @tourdesource Год назад

      @@davidfong Thanks for the tip!

  • @Dazza_Doo
    @Dazza_Doo 7 месяцев назад

    The Basics talks have nothing basic about it, and that's what we need.
    This information is needed. Well Done.
    I would like to see in the basics series: Zero cost abstractions for bare metal hardware. For example we don't want to use too many of any Virtuals, Dynamic Memory allocations. What can we use?

  • @mauriziocarli1973
    @mauriziocarli1973 Год назад +2

    Great talk... a lot of 'basic' topics very well explained... by the way: topics like 'declaration vs definition', 'linkage types,' 'one definition rules' and so on, could also be considered 'basic' as the same title specify, but not so easy to find on an online course or tutorial... so it's worth watching, definitely... thanks Bob

  • @chadmcintire4128
    @chadmcintire4128 4 года назад +7

    Your talks are just oozing with good information. Thank you very much for your work Bob!

  • @JoeBurnett
    @JoeBurnett 4 года назад +2

    Thank you for taking the time to present this.

  • @TheVigi99
    @TheVigi99 4 года назад +3

    Back to basics is always my favourite!

  • @bsuperbrain
    @bsuperbrain 4 года назад +2

    Very clear and concise talk.

  • @sparschlumpf
    @sparschlumpf 4 года назад +6

    Around minute 39, the linkage of g is never mentioned, even though it feels important to mention that it has *external* linkage, even if there is no header for it: it is neither static nor in an anonymous namespace nor inline. Having a second compilation unit with another g like that will have multiple definitions upon linking.
    This is kind of implicitly explained later in ODR rules with example 2, but seeing this is a very common issue it feels important to highlight.

  • @WilhelmDrake
    @WilhelmDrake 2 года назад

    Thank you Mr. Bob. Great talk.

  • @kamilziemian995
    @kamilziemian995 2 года назад

    Great talk on very important, and very underappreciated, topic.

    • @CppCon
      @CppCon  2 года назад +1

      Thank you for your comment, which is much appreciated!

  • @peterjohnson2752
    @peterjohnson2752 4 года назад +3

    Wonderful presentation! Thanks for your work

  • @АндрейБорисов-и4о

    Thanks Bob! Very good and informative video lesson!

  • @kuleden_
    @kuleden_ 4 года назад +1

    Bir programın yapısının nelerden oluştuğunu, derlenen programlama dilleri (C ve C++) ile ilgili temel konuları anlatan harika bir sunum.
    Özellikle programlamayı ilk kez #Python dili öğrenerek başlayan ve ileride C/C++ dillerini öğrenmek isteyenler için faydalı bilgiler içeriyor

  • @blkbunta
    @blkbunta 2 года назад +2

    thank you very much. it was very informative 🙂

  • @VictorPeraltaGomez
    @VictorPeraltaGomez 4 года назад +1

    Great presentation!👏🏻

  • @proz0239
    @proz0239 4 года назад +1

    Great talk!

  • @philmsproduction
    @philmsproduction 4 года назад

    32:00 shouldn't we remove the extern keyword for the actual definition?

    • @frydac
      @frydac 3 года назад +1

      you can, but don't have to, however I would argue you never want to do this with a mutable global variable, mutable global state has many drawbacks, but if you decide to use global state anyway (there are legit usecases) then use a meyers singleton.
      However if you have const global state and dont want a copy in every translation unit where you want to use that state, you can (have to) define them in a .cpp file something like (or use that singleton):
      extern const type name{ctor args};
      because const makes the object have internal linkage, and by adding extern you can override this to have external linkage anyway and you'll be able to refer to it from other translation units.
      And be aware that having a copy of the global state in several places can be faster than not having a copy (e.g maybe less cache misses), or not.. you'd have to measure (I think, I never have measure this usecase, it seems probable to me with my current experience/knowledge level).

  • @TienHuynh5312
    @TienHuynh5312 4 года назад

    thanks.

  • @ajit78910
    @ajit78910 4 года назад

    Thanks 💐🙏

  • @ElementaryWatson-123
    @ElementaryWatson-123 3 года назад

    Will we ever see the standardization of dynamic linking? The differences between .so in Linux and .dll in Windows adding a lot of headache.

  • @Moriadin
    @Moriadin 3 года назад +1

    What an abomination of a language...

    • @scahsaint6249
      @scahsaint6249 2 года назад

      What do you recommend?

    • @SisypheanRoller
      @SisypheanRoller 2 года назад +2

      Most of the time you're using c++, you don't even need to think about all these language lawyer ideas. All you need is your compiler, linker, and runtime (ld.so).