"it worked before and i didn't change anything!" here
anyway, i have a simple sketch for testing. its only job is to let the built in led blink twice a second. works fine but when i add an #include directive it seems like even setup isn't called anymore. when i comment the include out it works fine again. the library and the sketch both compile fine and without any warnings, compiler warnings is set to all.
all the library does is defining two classes, not creating any instances. if the library would be the problem the compiler, linker or something else in the line should throw at least some warnings?
where would i look for the problem?
thanks
edit: Solution: a file in the library folder had an "int main() {}" function. deleting that file solved the problem.
the #include for the arduino.h links in visual studio to a wrapper i made so i can see if compilation works. but it's not copied to the arduino library folder. tests have shown that this include is just ignored by the arduino ide. if i understood right the ide includes the native arduino.h by default so it's ignored because of the #ifndef.
This will surely get you into trouble if samples has not actually been allocated:
delete [] samples;
And, since you never check to see if the new actually succeeded....
Giving a function argument the same name as a member variable in the same scope is a terrible practice. Re-name one or the other, and get rid of all the "this->".
RayLivingston:
This will surely get you into trouble if samples has not actually been allocated:
delete [] samples;
And, since you never check to see if the new actually succeeded....
thanks, i will certainly have take a look on that.
Giving a function argument the same name as a member variable in the same scope is a terrible practice. Re-name one or the other, and get rid of all the "this->".
know what's funny? when i just started i learned it like that from books but someone said the same about your proposed style, back in the days it was on freenode. are there good reasons or is it just taste?
but both doesn't seem to be related to why the program freezes my arduino even before setup when all i do is #include'ing the file?
without the include:
Sketch uses 2234 bytes (6%) of program storage space. Maximum is 32256 bytes.
Global variables use 223 bytes (10%) of dynamic memory, leaving 1825 bytes for local variables. Maximum is 2048 bytes.
and with the include it's:
2332 bytes (7%) / 297 bytes (14%)
also the exported binaries differ.
so how do i make sure arduino uses the code i feed to it?
[quote author=Coding Badly date=1612256120 link=msg=4882020]
You're asking the wrong question. The compiler is not an imp messing with you.
The question to ask is "How many copies of Sample.cpp are on my computer?" Repeat that question for the other three files.[/quote]
it is! it does! well, maybe not an imp but a demon! if it would just do as i say there would be only two copies, one in my visual studio directory and one in my arduino lib. but i discovered the arduino IDE messes it all up, saving different versions in many places, uses caches or not or maybe, ... short: i would consider this the behaviour of a demon! and scientifically... considering how complex computers are these days it can't be finally proven that there aren't some demons in the system
anyway, i found the problem. my library has a file with an int main() {} (sic! without any return, neither visual studio nor arduino complained about the lack of the return...) but that function seemed to have overwritten some other main and since it's empty it gave the board some free time.
next questions: what exactly was overwritten and why didn't the arduino IDE complain about that? and why was that .cpp file used at all while i never included it anywhere? how do arduino libraries work, like what and how is processed of them? does arduino just swallow and compile the whole folder when i use just a single file or two??