Pues a eso me refiero, ¿si hay alguna formad e hacerlo?, ¿con estructuras y punteros o algo?
Pues a eso me refiero, ¿si hay alguna formad e hacerlo?, ¿con estructuras y punteros o algo?
Sí claro. En C18 no lo sé porque hace tiempo que no programo PIC18 pero las librerías nuevas de PIC32 están todas en C "emulando" C++: usando estructuras como si fuesen clases y llamandolas con punteros. Ahora que es "lioso de cojones" :P, tienes que ser bastante bueno en C como para seguir el hilo del código...
si no te importa podrías poner algún ejemplo sencillo de encender un led o algo y explicarlo un poco a ver si le pillo el toque?, se me ocurren cosas para hacer pero prefiero ver algo ya machacado por alguien así evitaré errores.
gracias de nuevo.
Es que veo que una vez crees un driver de esa manera es muy fácil añadirlo a tu proyecto y se vería todo más claro
he estado modificando un driver que tengo para medir temperatura con un termopar pero creo que no puedo hacerlo, no queda igual ni de lejos que con C++
¿sabes las razones de por qué torvalds se decante más por uno que por el otro?
Me refería si se puede hacer algo parecido a lo del constructor y las clases en C, he estado modificando un driver que tengo para medir temperatura con un termopar pero creo que no puedo hacerlo, no queda igual ni de lejos que con C++, el tema es que no veo la manera de hacer algo parecido al constructor de c++, sigo pensando soluciones pero no lo tengo nada claro, creo que no se podrá.
¿sabes las razones de por qué torvalds se decante más por uno que por el otro?
¿sabes las razones de por qué torvalds se decante más por uno que por el otro?
C++ is a horrible language. It's made more horrible by the fact that a lot
of substandard programmers use it, to the point where it's much much
easier to generate total and utter crap with it. Quite frankly, even if
the choice of C were to do *nothing* but keep the C++ programmers out,
that in itself would be a huge reason to use C.
In other words: the choice of C is the only sane choice. I know Miles
Bader jokingly said "to piss you off", but it's actually true. I've come
to the conclusion that any programmer that would prefer the project to be
in C++ over C is likely a programmer that I really *would* prefer to piss
off, so that he doesn't come and screw up any project I'm involved with.
C++ leads to really really bad design choices. You invariably start using
the "nice" library features of the language like STL and Boost and other
total and utter crap, that may "help" you program, but causes:
- infinite amounts of pain when they don't work (and anybody who tells me
that STL and especially Boost are stable and portable is just so full
of BS that it's not even funny)
- inefficient abstracted programming models where two years down the road
you notice that some abstraction wasn't very efficient, but now all
your code depends on all the nice object models around it, and you
cannot fix it without rewriting your app.
In other words, the only way to do good, efficient, and system-level and
portable C++ ends up to limit yourself to all the things that are
basically available in C. And limiting your project to C means that people
don't screw that up, and also means that you get a lot of programmers that
do actually understand low-level issues and don't screw things up with any
idiotic "object model" crap.
So I'm sorry, but for something like git, where efficiency was a primary
objective, the "advantages" of C++ is just a huge mistake. The fact that
we also piss off people who cannot see that is just a big additional
advantage.
If you want a VCS that is written in C++, go play with Monotone. Really.
They use a "real database". They use "nice object-oriented libraries".
They use "nice C++ abstractions". And quite frankly, as a result of all
these design decisions that sound so appealing to some CS people, the end
result is a horrible and unmaintainable mess.
But I'm sure you'd like it more than git.
Linus
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.
Bjarne Stroustrup (https://en.wikipedia.org/wiki/Bjarne_Stroustrup):CitarC makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.
voy a intentar todo eso que me explicas a ver que tal me sale, practicar practicar hasta la saciedad, por cierto y si no es abusar mucho ya de la confianza, ¿me indicas la librería gráfica a la que te refieres?.
A otra cosa que me confunde mucho al intentar lo de el constructor y las clases en c, el tema de configurar el hardware en arduino se puede hacer desde el constructor pero en c18 veo que se hace fuera en un archivo .h
lo de las clases lo tengo claro que es similar por no decir lo mismo que una estructura, pero lo del constructor eso me desorienta, veo que es como una función donde metes los punteros pero no sé si ahí se puede configurar el hardware, tengo que madurar todo esto todavía, ya entender lo de las clases y el constructor en c++ me costó como un día o dos más o menos...
A otra cosa que me confunde mucho al intentar lo de el constructor y las clases en c, el tema de configurar el hardware en arduino se puede hacer desde el constructor pero en c18 veo que se hace fuera en un archivo .h
Si utilizas variables globales dentro de un archivo en c y no las declaras externas fuera de ese archivo, es como si fueran variables privadas de una clase.
Sólo podrás verlas y manejarlas con las funciones de ese módulo (archivo) de c.
Así te aseguras que el resto del programa no las toque, sólo tu librería. Eso te dará el control que quieres sobre las variables globales.
Un saludo.