#jogamp @ irc.freenode.net - 20160608 05:06:16 (UTC)


20160608 05:06:16 -jogamp- Previous @ http://jogamp.org/log/irc/jogamp_20160607050616.html
20160608 05:06:16 -jogamp- This channel is logged @ http://jogamp.org/log/irc/jogamp_20160608050616.html
20160608 06:39:04 * elect (~GBarbieri@anon) has joined #jogamp
20160608 06:39:09 <elect> hey
20160608 07:31:57 * Eclesia (~husky@anon) has joined #jogamp
20160608 07:32:25 <Eclesia> o/
20160608 07:43:29 * jvanek (jvanek@anon) has joined #jogamp
20160608 08:58:06 * xranby (~xranby@anon) Quit (Read error: Connection reset by peer)
20160608 09:14:35 * xranby (~xranby@anon) has joined #jogamp
20160608 10:08:16 * xranby (~xranby@anon) Quit (Ping timeout: 264 seconds)
20160608 10:22:14 * xranby (~xranby@anon) has joined #jogamp
20160608 12:43:21 * xranby (~xranby@anon) Quit (Ping timeout: 276 seconds)
20160608 13:40:51 <elect> how can I print a string of chars in C?
20160608 13:41:09 <elect> because if I have
20160608 13:41:20 <elect> (const unsigned char*)data
20160608 13:41:22 <elect> it works
20160608 13:41:38 <elect> but (unsigned char*)data
20160608 13:41:40 <elect> doenst work
20160608 13:41:51 <elect> or at least I get only 2 characters
20160608 13:42:05 <elect> printf("%s\n", data);
20160608 13:45:05 <zubzub> do you want to prin tthe textual representation?
20160608 13:45:11 <elect> yes
20160608 13:45:12 <zubzub> and is it null terminated?
20160608 13:45:27 <elect> it shouldn't
20160608 13:45:37 <zubzub> well then printf doesnt know where it ends
20160608 13:45:50 <elect> I have the size
20160608 13:45:58 <elect> how can I iterate over the single chars?
20160608 13:46:22 <zubzub> by incrementing the pointer and dereferencing it
20160608 13:46:35 <elect> that is?
20160608 13:46:51 <zubzub> char content = *data++
20160608 13:47:15 <zubzub> *(data++) is probably better
20160608 13:47:27 <zubzub> or in a loop
20160608 13:47:32 <zubzub> *(data+i)
20160608 13:47:39 <Eclesia> my eyes are bleeding
20160608 13:47:58 <zubzub> <3 C
20160608 13:48:04 <elect> *data[i] returns error
20160608 13:48:15 <zubzub> http://stackoverflow.com/questions/2137779/how-do-i-print-a-non-null-terminated-string-using-printf
20160608 13:48:27 <zubzub> because data[i] already dereferences it
20160608 13:48:39 <zubzub> so *data[i] is a double dereference
20160608 13:48:44 <zubzub> = error
20160608 13:49:15 <zubzub> char bleh = data[i] is enough
20160608 13:49:34 <zubzub> but you should never iterate over char arrays if you want to print them
20160608 13:49:50 <zubzub> there are a million different printf functionalities that already solve what you want to do
20160608 13:50:30 <elect> printf("%s\n", compressed_ttf[i]);
20160608 13:50:51 <elect> "espression must be a pointer to a complete object type"
20160608 13:51:40 <zubzub> does it return void* ?
20160608 13:51:51 <elect> ah yeah
20160608 13:51:59 <zubzub> void doesnt have a size
20160608 13:51:59 <elect> sorry
20160608 13:52:02 <zubzub> so it can't dererence it
20160608 13:52:10 <zubzub> *dereference it
20160608 13:52:11 <elect> shall I cast it?
20160608 13:52:13 <zubzub> yes
20160608 13:52:43 <elect> void* compressed_ttf = ImGui::MemAlloc((size_t)compressed_ttf_size);
20160608 13:52:43 <elect> Decode85((const unsigned char*)compressed_ttf_data_base85, (unsigned char*)compressed_ttf);
20160608 13:52:58 <elect> compressed_ttf is the data I am trying to read
20160608 13:53:11 <elect> printf("%s\n", (unsigned char*)compressed_ttf[i]); fails too
20160608 13:53:41 <zubzub> because you are [i]'ing compressed_ttf
20160608 13:53:45 <zubzub> which is a void pointer
20160608 13:53:55 <zubzub> [i] is dereferencing it at an index
20160608 13:54:15 <zubzub> void pointer can't be dereferenced
20160608 13:54:48 <elect> so do I have a chance to get its textual representation?
20160608 13:55:18 <zubzub> what does decode do?
20160608 13:55:28 <zubzub> uncompress arg0 into arg1 ?
20160608 13:55:33 <elect> yep
20160608 13:55:52 <zubzub> change the type of compressed_ttf to char*
20160608 13:56:00 <elect> actually it doesnt compress yet, it perform only a base decoding
20160608 13:56:21 <elect> then ImGui::MemAlloc complains
20160608 13:56:59 <zubzub> odd
20160608 13:57:18 <zubzub> well it does looklike C++ so yeah...
20160608 13:57:36 <zubzub> void* is just an address to memory
20160608 13:57:37 <elect> https://github.com/ocornut/imgui/blob/master/imgui_draw.cpp#L1239
20160608 13:57:46 <zubzub> so is char*
20160608 13:57:59 <zubzub> the only difference is that char* tells the copmiler what to expect at that address
20160608 13:58:13 <zubzub> while void* is like a 'supertype'
20160608 13:58:40 <zubzub> ie any type of data could live at this memory
20160608 14:02:35 <zubzub> C 101 really :p
20160608 14:03:17 <elect> printf("%s\n", ((unsigned char*)compressed_ttf)[i]); compiles but crashes
20160608 14:04:46 <zubzub> that's because you are dereferencing a char pointer to a char value
20160608 14:04:52 <zubzub> printf expects a pointer
20160608 14:05:43 <zubzub> have you read the stack overflow link I posted?
20160608 14:05:50 <elect> I tried
20160608 14:06:02 <elect> but it crashes
20160608 14:06:15 <elect> I supposed what I thought is the size is wrong
20160608 14:07:46 <elect> or because of something I can't understand
20160608 14:08:08 <elect> which is highly probable
20160608 14:10:41 <zubzub> you can try printing the hex values and see if they make sense to you
20160608 14:10:51 <elect> %x?
20160608 14:10:53 <zubzub> ie if the hex values represent ascii
20160608 14:11:24 <zubzub> http://stackoverflow.com/questions/11992677/printf-raw-data-to-a-fixed-length-hex-output
20160608 14:12:02 <elect> the curious thing is that this
20160608 14:12:09 <zubzub> *or* you can learn gdb! :p
20160608 14:12:16 <elect> printf("init\n");
20160608 14:12:16 <elect> printf("%s\n", (const unsigned char*)compressed_ttf);
20160608 14:12:16 <elect> printf("end");
20160608 14:12:42 <elect> prints this
20160608 14:12:43 <elect> http://imgur.com/ghPgOye
20160608 14:12:50 <zubzub> if compressed_ttf is a null terminated string than that code is ok
20160608 14:13:06 <elect> and those two strange characters are the same I get if I loop
20160608 14:13:13 <elect> no sorry
20160608 14:13:23 <elect> if I call
20160608 14:13:27 <elect> printf("%.*s", 2, compressed_ttf);
20160608 14:14:43 <elect> so the third byte is equal to \0?
20160608 14:15:39 <zubzub> probably
20160608 14:15:56 <zubzub> see the stack overflow link I posted to get the hex values
20160608 14:15:58 <elect> printf("%.*s", 50, compressed_ttf); returns the same
20160608 14:16:46 <elect> the struct is mandatory?
20160608 14:17:38 <elect> ok no
20160608 14:18:57 <zubzub> you can dereference your pointer with foo[i] and then print it's raw value
20160608 14:19:14 <elect> printf("%02x\n", ((unsigned char*)compressed_ttf)[i]); seems working
20160608 14:22:35 <elect> thanks zubzub
20160608 14:22:40 <elect> sorry for the nubness
20160608 14:24:05 <zubzub> np :)
20160608 14:26:11 * xranby (~xranby@anon) has joined #jogamp
20160608 14:28:13 <zubzub> and just *now* xranby joins
20160608 14:28:18 <zubzub> that's no coincidence
20160608 14:30:03 <elect> >.>
20160608 14:53:15 * SHC (~quassel@anon) has joined #jogamp
20160608 15:35:01 * elect (~GBarbieri@anon) Quit (Ping timeout: 240 seconds)
20160608 15:35:04 * xranby2 (~xranby@anon) has joined #jogamp
20160608 15:37:33 * xranby (~xranby@anon) Quit (Ping timeout: 276 seconds)
20160608 16:01:11 * Eclesia (~husky@anon) Quit (Quit: Leaving.)
20160608 16:58:22 * dwbrite (4474ac1d@anon) has joined #jogamp
20160608 17:29:17 * jvanek (jvanek@anon) Quit (Quit: Leaving)
20160608 17:46:20 * monsieur_max (~maxime@anon) has joined #jogamp
20160608 18:16:38 * SHC (~quassel@anon) Quit (Remote host closed the connection)
20160608 19:12:36 * dwbrite (4474ac1d@anon) Quit (Ping timeout: 250 seconds)
20160608 19:30:52 * monsieur_max (~maxime@anon) Quit (Quit: Leaving.)
20160608 21:43:09 * Eclesia (~eclesia@anon) has joined #jogamp
20160608 22:18:55 <Eclesia> always a lot of work to make tutorials :/ Viva Markdown
20160608 22:19:15 <Eclesia> first draft : http://unlicense.developpez.com/tutorials/widgets/ what do you think ?
20160608 22:20:03 <Eclesia> not much content, more like the theme and page setup, that's all
20160608 22:22:06 <Eclesia> good night ++
20160608 22:22:10 * Eclesia (~eclesia@anon) Quit (Quit: Leaving.)
20160609 05:06:16 -jogamp- Continue @ http://jogamp.org/log/irc/jogamp_20160609050616.html