Calyp has quit [Quit: gone working on freeconomy =o)]
<whitequark>
viric: sharc?
<whitequark>
like an evil child of sparc and sh-4?
dlan^ has quit [Ping timeout: 248 seconds]
dlan^ has joined #qi-hardware
dlan^ has quit [Ping timeout: 260 seconds]
dlan^ has joined #qi-hardware
<wpwrak>
grmbl echo '#define usb urb' >>include/linux/usb.h
<wpwrak>
about 80% of all failed compilations are because of that typo :-(
porchaso0 has joined #qi-hardware
viric_ has joined #qi-hardware
LunaVorax has quit [Ping timeout: 256 seconds]
porchao has quit [*.net *.split]
viric has quit [*.net *.split]
Fallenou_ has joined #qi-hardware
panda|z has joined #qi-hardware
wpwrak has quit [Excess Flood]
kill\switch has quit [Excess Flood]
wpwrak has joined #qi-hardware
kill\switch has joined #qi-hardware
Fallenou has quit [*.net *.split]
panda|znc has quit [*.net *.split]
DocScrutinizer05 has quit [Disconnected by services]
DocScrutinizer05 has joined #qi-hardware
baba has joined #qi-hardware
fire has quit [Ping timeout: 258 seconds]
xiangfu has joined #qi-hardware
unclouded has quit [Ping timeout: 240 seconds]
rz2k has joined #qi-hardware
unclouded has joined #qi-hardware
dlan^ has quit [Remote host closed the connection]
dlan^ has joined #qi-hardware
valhalla has quit [Ping timeout: 252 seconds]
valhalla has joined #qi-hardware
kilae has joined #qi-hardware
jekhor has joined #qi-hardware
<viric_>
whitequark: I don't know. some dsp :)
<larsc>
viric_: no
<larsc>
whitequark: short for super hyper architecture or something like that ;)
<larsc>
it's a DSP from ADI
<qi-bot>
[commit] Werner Almesberger: fw/include/atusb/: move shared protocol definitions from ep0.h to atusb.h (master) http://qi-hw.com/p/ben-wpan/12d3401
<qi-bot>
[commit] Werner Almesberger: atusb/fw/board.h: de-duplicate USB ID definitions (now originate from atusb.h) (master) http://qi-hw.com/p/ben-wpan/2d43876
<wpwrak>
Super Harvard Architecture ;-)
<qi-bot>
[commit] Werner Almesberger: fw/include/atusb/ep0.h (USB_TYPE_VENDOR): avoid conflict with /usr/include/usb.h (master) http://qi-hw.com/p/ben-wpan/16dd767
jekhor has quit [Read error: Operation timed out]
<viric_>
super harvard architecture, no?
<viric_>
although super hyper sounds nice ;)
<larsc>
yes, super harvard is correct
<kyak>
int array[100]; - is it a definition or merely a declaration?
<viric_>
definition
<viric_>
'extern int array[100];' would be a declaration
<kyak>
so the memory gets allocated after this line of code, right?
<viric_>
yes
<kyak>
ok, i see
viric_ is now known as viric
<larsc>
if it is a global variable the memory is always allocated for the lifetime of the program
<viric>
also, if in a function body, it's prefixed by 'static'
<viric>
but if you have: int f(int array[100]) // it's different :)
<kyak>
yep, it's a declaration of function 'f'.. But shouldn't it be int f(int array[])?
<viric>
it has a slightly different meaning
<viric>
if it includes the 100
<kyak>
whta is it?
<viric>
hm I've to think this one
<larsc>
so, for function parameters 'int array[X]' is the same as 'int *array'
<larsc>
at least for the generated code
<viric>
yes
<larsc>
but I think the typechecker might complain if you pass a int array[3] to a function that expects a int array[2]
<viric>
hm I don't think so
<viric>
For bidimensional, it's more clear: int x[10][] is different than int **x
<kyak>
larsc: "the typechecker might complain" do you mean that the code won't compile (or give warnings)?
<kyak>
and then what's the difference between 'int *array' and 'int array[]' for function arguments?
<larsc>
give warnings, but it looks like i'm mistaken
<larsc>
the compiler compiles int array[3] as int *array
<larsc>
kyak: I think none
<larsc>
It just looks nicer ;)
<viric>
I agree
<viric>
it can become a difference in more dimensions, as I think "int array[][]" doesn't work.
<lindi->
well if it is array[3] then the compiler can assume that you are not going to access array[-1] or array[3]?
<viric>
lindi-: but I remember there was something in the spec about that
<viric>
mh there is also: void fun(char buffer[static 2048])
<kyak>
oh common.. what's that?
<kyak>
'static 2048' looks weird
<viric>
:)
<viric>
that asks the compiler "please check that there will be at least 2048"
<viric>
the compiler *may* then check.
<kyak>
so the compiler will check the caller? this seems too sophisticated for a compiler
<viric>
*may*
<kyak>
viric: could you explain what's 'int **x'?
<viric>
a pointer to pointers to int
<viric>
kyak: do you know 'cdecl'?
<viric>
install it :)
<kyak>
nope, i don't know; i'll check it out
<viric>
cdecl> explain int **x
<viric>
declare x as pointer to pointer to int
<kyak>
oh, nice
<larsc>
or cdecl.org
<kyak>
cdecl> explain static 2048
<kyak>
syntax error
<kyak>
--)
<viric>
you can't write partial declarations! :)
<kyak>
nah, it doesn't understand the complete one (given by you above) as well
<viric>
mh bad
<larsc>
it doesn't understand function declarations at all
<kyak>
viric: so the multidimensional array is just a collection of pointers to simple arrays?
<kyak>
ah yeah, int x[2][3] is in contigous memory, if i remember
<viric>
like: int f(int x[][3])
<kyak>
can we write int x[2][3][4]?
<viric>
yes
<larsc>
int a[2][3] and a[x][y] is like int a[6] and a[x * 3 + y]
<viric>
kyak: the Ansi C spec I have is 554 pages long. Imagine.
<viric>
kyak: what do you write?
<kyak>
viric: i'm currently one third through K&R, that's how much i know about ANSI C :)
<viric>
:) ok
jekhor has joined #qi-hardware
<kyak>
viric: i'm just studying a little bit, not writing anything at the moment
<viric>
ok
<kyak>
viric: btw, can you send me that ANSI C spec? I have the txt version, but it's not very convenient
<viric>
ok but don't tell anyone
<kyak>
even the police?
<viric>
the police may know already
baba has quit [Quit: WeeChat 0.4.0]
baba has joined #qi-hardware
jekhor has quit [Ping timeout: 256 seconds]
unclouded has quit [Ping timeout: 240 seconds]
Calyp has joined #qi-hardware
jekhor has joined #qi-hardware
jekhor has quit [Ping timeout: 255 seconds]
Calyp has quit [Quit: gone working on freeconomy =o)]
<wpwrak>
int array[2]; is equivalent to extern int array[2]; if in a global scope or equivalent to auto int array[2]; if in local scope. it never defaults to "static"
LunaVorax has joined #qi-hardware
<wpwrak>
furthermore, if "extern" and without initializer, it can be both declaration and definition. the linker picks one and makes that the actual definition.
<wpwrak>
if one has an initializer, then it becomes the definition. if more than one has an initializer, you get an error
<viric>
you can't have two modules, in global scope saying: int array[2];
<wpwrak>
try it ;-)
<viric>
damn c :)
<wpwrak>
it's perfectly consistent :)
<viric>
gcc works
<viric>
in tcc, it fails
<viric>
error: 'array' defined twice
<wpwrak>
now we know which compiler complies to standards :)
<viric>
isn't it a linker thing?
<viric>
not compiler
<wpwrak>
well, the compiler has to let it pass
<viric>
I don't mean multiple "int array[2];" in a module
<viric>
I mean "int array[2];" in every module
<wpwrak>
you could actually have int array[2]; int array[2]; int array[2]; and shouldn't get any complaint
<wpwrak>
there's no difference
<viric>
how not?
<wpwrak>
what you can't have is mire than int array[2] = { 0 };
<wpwrak>
more than one
<viric>
hm
<viric>
ok, gcc generates 'C' (nm naming) for "int array[2];"
rjeffries has quit [Ping timeout: 245 seconds]
<viric>
while tcc generates 'B'
<viric>
c has lots of dark corners
<wpwrak>
just remember that you usually don't have to write "extern". then it all follows logically.
<wpwrak>
the only case where you NEED extern is if you're in a function-local scope and want to access something global (and are too cool to declare it at a global scope)
<viric>
maybe it's just about different versions of c?
<wpwrak>
yeah, those long before K&R may be different. and maybe once skynet takes over, it'll make some changes as well ;-)
<wpwrak>
and of course, non-standards-compliant compilers may also have some different ideas :)
<viric>
hehe you feel very sure
<wpwrak>
i think what confuses you is that you read "extern" as "this-is-a-declaration". this isn't what it means.
<viric>
ok
<viric>
we've to report to tcc then :)
<wpwrak>
it's common style to say explicitly "extern" when declaring a global variable. to make it clear to the human reader. but for the (compliant) compiler, this bears no meaning.
<viric>
I'll try clang
<viric>
ok, clang does 'right'
<wpwrak>
anything else would have surprised me :)
<whitequark>
wpwrak: um, I think that you do
<whitequark>
`int a;` translates to a COMMON linkage, whereas `extern int a;` to EXTERN (or however it's named)
<wpwrak>
in a global scope, where would you see a difference ?
<whitequark>
wpwrak: I'm fairly certain it has something to do with initializers.
<wpwrak>
yes. initializers change everything. they turn a declaration (which can implicitly become a definition) into an explicit definition
megha has joined #qi-hardware
baba has quit [Ping timeout: 256 seconds]
<whitequark>
wpwrak: yes, and I think that a declaration with `extern` cannot implicitly be changed to a definition.
<whitequark>
isn't that the point of `extern`?
<whitequark>
(in this context)
<wpwrak>
no. also int a; (in global scope) mens exactly the same as extern int a;
<wpwrak>
try it :) you can do it all in the same .c file
<whitequark>
the symbols have different linkage. actually, `extern int a;` for some reason does not appear in the symbol table at all.
<wpwrak>
funny. but the effect is still the same. whether an unreferenced item actually gets placed in the object file is beyond the scope of the C standard :)
<whitequark>
ok ok :)
<wpwrak>
it's a bit surprising, though, that the compiler would actually make a difference here. not sure why. maybe it's for mixed-language programming
<kyak>
you know what? you make me feel good :) now i really am sure that you can't learn C
<kyak>
a lot of dark corners, as viric said
<kyak>
"one can't learn C", that's what i meant
<kyak>
also i have to read the above discussion again.. Got a bit lost
<kyak>
ok, so int array[2]; is a declaration if it is in a global scope?
<wpwrak>
ah no, there is actually a difference. it's not very clearly expressed in K&R 2nd ed., but "extern" removes the property of a declaration being a tentative definition. so what gcc does reflects this exactly.
<kyak>
what happens if i have int array[2]; int array[2]; and then have array[2] = { 0 };? Which one of them will be defined?
<wpwrak>
in other words, in global scope, you can always change "extern FOO;" to "FOO;" but you can only sometimes change "FOO;" to "extern FOO;"
<wpwrak>
kyak: there are three types: extern int a; /* declaration */ int a = 0; /* declaration and definition */ int a; /* declaration and tentative definition */
rz2k has quit [Read error: Connection reset by peer]
<wpwrak>
you can have any number of declarations and any number of tentative definitions but only zero or one (non-tentative) definition. and if you're actually using the thing, you need at least one definition, be it tentative or not.
<wpwrak>
so int a; int a; int a; int a; is okay
<whitequark>
by the way
<wpwrak>
extern int a; extern int a; extern int a; is okay too. but you don't have a definition yet. if you want one, you need either int a; or int a = something;
<kyak>
ok, but how are tentative defintions work together?
<whitequark>
wpwrak, you seem to like C, Unix tools and perversions
<wpwrak>
the linker merges the tentative definitions into one
<kyak>
wpwrak: ok, now it's more clear
<kyak>
thanks!
<kyak>
is it how it's called in K&R - tentative definition? Or is it implicit definition?
jurting has joined #qi-hardware
<wpwrak>
that's how K&R call it
<wpwrak>
whitequark: it's always fun to lex languages where newlines act as terminators :)
<wpwrak>
especially since you generally don't want to do the python thing :)
<whitequark>
wpwrak: oh there's more
<whitequark>
I especially like the joke about "(ab)using [lookahead] LALR(1) up to (1)"
<whitequark>
(also the dude who translated it is awesome.)
<whitequark>
*[lookahead in]
jekhor has joined #qi-hardware
woakas has quit [Ping timeout: 258 seconds]
jurting has quit [Ping timeout: 246 seconds]
Jurting_pc2 has quit [Ping timeout: 258 seconds]
woakas has joined #qi-hardware
Calyp has joined #qi-hardware
rz2k has joined #qi-hardware
kuribas has joined #qi-hardware
xiangfu has quit [Ping timeout: 252 seconds]
emeb has joined #qi-hardware
xiangfu has joined #qi-hardware
pcercuei has joined #qi-hardware
xiangfu has quit [Ping timeout: 252 seconds]
xiangfu has joined #qi-hardware
xiangfu has quit [Ping timeout: 256 seconds]
xiangfu has joined #qi-hardware
DocScrutinizer05 is now known as sysbot
sb0 has joined #qi-hardware
<sb0>
hi wolfspraul, sharism.cc is still down ...
sysbot is now known as DocScrutinizer05
<wpwrak>
the killer easter bunny ate it :)
pcercuei has quit [Ping timeout: 272 seconds]
pcercuei has joined #qi-hardware
kristianpaul has quit [Read error: Connection reset by peer]
<kyak>
i continue to open new things for myself. How do you like this mixed variable/function declaration: double sum, atof(char []); Also it is interesting that we can declare functions inside a calling function
<kyak>
in fact, i don't know yet if it any different to declaring the function outside of the calling function (but in the same file scope)
<pcercuei>
It is cleaner to declare it outside, I think
<kyak>
so it seems to be a matter of personal taste
<pcercuei>
larsc, I have a question
<pcercuei>
larsc: I want to create a joystick driver for opendingux, so that the buttons of the gcw0 return joystick events instead of key events. The front buttons could use gpio-keys with no problem, but the analog stick would have to be integrated as well on the driver; is there a way I can smartly re-use gpio-keys from another driver without duplicating all of its code?
<pcercuei>
and still having the front buttons and the analog appear on the same joystick device...
FrankBlues has joined #qi-hardware
jurting has joined #qi-hardware
<wpwrak>
kyak: with local declarations, you risk creating homonymous but incompatible types
jurting has quit [Ping timeout: 264 seconds]
wej has joined #qi-hardware
<kyak>
wpwrak: do you mean declaring a function that would shadow existing declaration? Wouldn't it be caught by compiler?
<wpwrak>
i was thinking more of structs, enums, and unions.
<pcercuei>
kyak: not if you use weak functions, I think
<kyak>
i don't think i understand you..
<wpwrak>
and shadows will be caught if -Wshadow is set
kuribas has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
<wpwrak>
you can make all sorts of variations of this theme
<pcercuei>
kyak: it's a GCC feature (are you talking about C/C++?): a "weak" function is a function that can be redefined
<kyak>
wpwrak: let me take a minute to think about it :)
<kyak>
pcercuei: i see, it's an interesting concept. Some short googling says that it is specific to ARM
<wpwrak>
kyak: it's a bit of a brain twister ;-)
<pcercuei>
kyak: hmmm I think it works on more architectures
<pcercuei>
from the GCC manual: "Weak symbols are supported for ELF targets"
<kyak>
pcercuei: yea, the information i found is not about GCC compiler at all, sorry for confision :)
<pcercuei>
ok
pcercuei has quit [Quit: Bye]
<kyak>
wpwrak: so here is your trick. You call the 'foo' function from main. Compiler knows it is a function because it is an expression followed by a left parentheses. You pass a 'bar' structure into the 'foo' function, and the 'bar' structure is also named 'foo' by some evil genius. This structure is global scope. What's interesting in 'foo' function is that you declare the 'foo' structure again in the parameter list.
<kyak>
this last trick doesn't really work, the compiler returns error: incompatible type for argument 1 of 'foo'
xiangfu has quit [Ping timeout: 260 seconds]
<wpwrak>
yup. here's a version that looks less suspicious but has exactly the same problem: http://pastebin.com/b5QPEmwP
<wpwrak>
(also note the barrage of compiler complaints :)
<wpwrak>
yes. get rid of the implicit local declaration of the struct and all works :)
<kyak>
wpwrak: here's a little trick for you: char abc[3] = "abc"; - what's going to be the size of abc and what would be inside?
LunaVorax has quit [Read error: Connection reset by peer]
LunaVorax_ has joined #qi-hardware
LunaVorax_ is now known as LunaVorax
<wpwrak>
size will be 3. content .. hmm. checking k&r ...
<wpwrak>
it's probably a special case
<kyak>
yeah
<wpwrak>
yup. A8.7 "As a special case [...]" :)
wej has quit [Ping timeout: 264 seconds]
<kyak>
hm, actually it doesn't really explain in K&R
<kyak>
char abc[] = "abc"; //abc size is 4
<kyak>
char abc[3] = "abc"; //abc size is 3
<wpwrak>
it does :)
<kyak>
i'm reading the paragraph again :)
wej has joined #qi-hardware
<kyak>
oh yes
<wpwrak>
nice. killed the kernel so hard it didn't even make a sound :)
<qi-bot>
[commit] Werner Almesberger: fw/include/atusb/ep0.h: protect also USB_DIR_IN and USB_DIR_OUT (master) http://qi-hw.com/p/ben-wpan/3e749c3
<qi-bot>
[commit] Werner Almesberger: atusb/fw/mac.c (handle_irq): only handle TRX_END; never fall back to seq ints (master) http://qi-hw.com/p/ben-wpan/60ee82b
<qi-bot>
[commit] Werner Almesberger: atusb/fw/mac.c (handle_irq): move frame reception to separate function (master) http://qi-hw.com/p/ben-wpan/d76bdf6
<qi-bot>
[commit] Werner Almesberger: atusb/fw/include/atusb/usb-ids.h: remove (and adapt former users) (master) http://qi-hw.com/p/ben-wpan/dab0d18
<qi-bot>
[commit] Werner Almesberger: include/atusb/atusb.h: salvage cute explanation of 0x1540 from usb-ids.h (master) http://qi-hw.com/p/ben-wpan/ad70d7c
<qi-bot>
[commit] Werner Almesberger: atusb/fw/usb/: enable MCU reset on USB bus reset after config selection (master) http://qi-hw.com/p/ben-wpan/9b2696b