3 ms·
Nice, lots of detailed explanation! For people interested, to use them in a C/C++ context, feel free to have a look at my Quaternion-Library. https://github.c
by EllipticCurve 10y ago
Nice, lots of detailed explanation!
For people interested, to use them in a C/C++ context, feel free to have a look at my Quaternion-Library.
https://github.com/MauriceGit/Quaternion_Library https://github.com/MauriceGit/Quaternion_Library
- jordigh 10y agoThis looks like C. Why do you call it "C/C++"? It could just as well be C/ObjC, right?
- generic_user 10y agoC and C++ share the same memory model and can be called quite easily form each other with the use of an 'extern "C"'. It's a common practice to write libraries in C for flexibility, (many languages can ingest C) and use the 'extern "C"' for use in C++ code. You can also write a thin C++ class wrapper for a more native object oriented interface.
- jordigh 10y agoBut all of this is true for ObjC too. How come people write C/C++ to describe pure C code but not C/ObjC? C is as much of a subset of ObjC as it is a subset of C++. It's funny people don't do this as much with other languages. For example, nobody describes pure Javascript as "js/html" even though you can have lots of js inside HTML code.
- EllipticCurve 10y agoTrue. I'll skip the C++ mentioning, as it is clear for any C++ developer, that you could just use it as extern C.
- generic_user 10y agoIf you intend for your library to be used in both C and C++ then your doing yourself a favor by using C/C++ for the simple fact that this is marketing to C++ programmers that they can use the library who may not be aware that that is the case. so at the bare minimum C/C++ will possibly increase your user base. (edit) You should not assume that C++ programmers are going to wade through your library code and rewrite your library with the proper signatures. You as the library writer should have done that and tested it, then advertised to prospective users that your library is ready for use with C++.
- generic_user 10y agoIts an interesting point. C is actually part of of the C++ standard. Within the ISO C++11 standard there is the C99 standard with some adjustments and exclusions. The integration is quite tight. So one can say C/C++ with some clarity. Library writers often go thorough a lot of work to write extensive object oriented interfaces around C libraries. And they intend that the user use the C++ version not just import the C version in there C++ code. So in that case it is a necessity to use C/C++ because there are two separate interfaces. In the general case I would guess that 'most' C programmers write some C++ and vise versa. So you have a very large overlap of C/C++ programmers. Objective C on the other hand is probably a significantly smaller group and is simply not big enough for C/C++ communities to think to much about.
- jordigh 10y ago> In the general case I would guess that 'most' C programmers write some C++ and vise versa. That's not what I've seen. People usually either write C++ exclusively or C exclusively and hate the other language (probably more C writers that hate C++ than C++ writers that hate C). Some people write very C-accented C++, with mallocs and frees instead of news and deletes and so forth (these are usually people who prefer C over C++ but are writing C++ for whatever reason). I guess those people could be said to be writing "C/C++". But in general I think people overestimate how close the two language communities are. What I have seen is that people like one language and deride the other.
- generic_user 10y agoThere are some people that probably get to worked up about it especially on the internet as you said. But in a professional environment where you have deadlines and a budget you don't have the luxury to be a language purist. You have to use libraries and choose from whats available and whats the best choice often that means mixing C and C++. I'm not saying that people necessarily like to code in C if they prefer C++ or the other way around but they will often have to. And so have some competency weather they like it or not.
- EllipticCurve 10y agoThat was my thinking. But as most C++ developers already know this, I'll skip the C++ mentioning :)