« first day (246 days earlier)      last day (2613 days later) » 

7:37 AM
In dev-c++ how to include static library in static library?
38 D:\Material\C++LOGO\New folder\dlltt\main.cpp undefined reference to `_imp__glLightfv@12'
anyone?
 
what did you try?
 
@MartinMatilla Sir, i put -lopengl32
-lglu32
-lglut32 in project still not work. Also put this in library project its still not work.
 
it seems like you are not linking to the glLight implementation
then its missing the location of those libraries
 
@MartinMatilla glLight in function test which is in static library which i compile.
 
what is the path of the library?
is this path set in the linking?
 
7:47 AM
@MartinMatilla i use -lglt, -l glut32, -lopengl32.
@MartinMatilla I read this but not usefull.
 
with that you tell the linker to link to a library called opengl
but you are not telling where it is located
another issue may be that glLight is not defined inside the library
can you look at the header definitions of the library?
 
@MartinMatilla glLight is include in header. If i not include library and just use main program with opengl it work.
@MartinMatilla But problem is i need to put some opengl function static library and include it main program. Which is not working.
 
8:07 AM
@AlexCerry did you set the path of the library?
-L/my/opengl/dir -lopengl32
 
@MartinMatilla during build static library?
 
during the application build
 
@MartinMatilla Yes. I include. During build program. There is no error library not found.
 
then you are doing everything right
google up you problem, i can't help you more
 
@MartinMatilla Google also did not help.
 
8:35 AM
error is look like this:
dlltt.a(main.o): In function `ZN9MathFuncs11MyMathFuncs4testEv':
D:\Material\C++LOGO\New folder\dlltt/main.cpp:40: undefined reference to `_imp__glLightfv@12'
D:\Material\C++LOGO\New folder\dlltt/main.cpp:41: undefined reference to `_imp__glLightfv@12'
D:\Material\C++LOGO\New folder\dlltt/main.cpp:42: undefined reference to `_imp__glLightfv@12'
D:\Material\C++LOGO\New folder\dlltt/main.cpp:43: undefined reference to `_imp__glLightfv@12'
collect2.exe: error: ld returned 1 exit status
 
9:01 AM
Hi, two questions: If a type is defined through a chain of typedefs can I just use the original type or do I have to watch out for something ? and: Do struct variable names and struct names "matter" when compiled ?
 
1. you can use the original name. the dev that created the typedef did it for some reason, watch out for that. if its just to reduce verbosity then its ok
2. what do you mean "matter"?
 
Elaboration on the second question: Lets say I define my own struct stat from the stat syscall, can I use my own names or do i have to use the predifned ones ?
its hard to describe what i mean, I can give some code if needed
 
expand on " I define my own struct stat from the stat syscall"
you create a new struct with the same fields?
 
@AlexCerry Missing -lgl or similar linker command?
 
yes waht Im asking if the types are defined the same, it should not matter what I name them, because at runtime the fields will get filled by a certain offset and not by name right ?
 
9:08 AM
@wilx what mean?
 
@AlexCerry If you are building with static libraries, chances are you have to define some preprocessor symbol so that the function declarations are not decorated with __declspec(dllimport) or similar annotation.
 
@wilx ok i try.
 
@zython hmh I see. I think so, you should be able to "cast" from one to another, but Im not 100% sure. I would wait for a more experienced answer
 
This seems similar to what you want. They define -DFREEGLUT_STATIC -DGLEW_STATIC
 
@MartinMatilla ok thanks so far
 
9:17 AM
@zython Don't define struct stat and stat just to save one #include directive
If you read the manpage, you'll see the order of the fields isn't specified
 
thing is I am writing everything from scratch, so I cant include anything
 
Also the implementations are permitted to add additional fields
 
@zython can you write a little code snippet to illustrate what exactly you need to solve?
 
gimme a minute
 
define "from scratch"
 
9:19 AM
"everything from scratch" what, are you actually implementing POSIX
 
also why from scratch
 
I am writing a pastebin clone from scractch invoking the syscalls myself without the standard library
 
@ratchetfreak my guess is to add purity of some sort :)
 
code coming in a bit
 
the syscalls and what they expect should be well defined
 
9:24 AM
@zython That seems profoundly stupid and useless thing to do.
 
@wilx let the man study whatever he wants :) I doubt he's a paid programmer atm
 
gist: 00e29c43d3804ec819bc54d25752cd14, 2017-03-14 09:23:32Z
My defined struct for now:

Question is can I change the variable names or do they have to be the same ?
It shouldnt matter if the types and therefore the offset is the same, right ?

typedef struct {
	dev_t     st_dev;         /* ID of device containing file */
	ino_t     st_ino;         /* inode number */
	mode_t    st_mode;        /* file type and mode */
	nlink_t   st_nlink;       /* number of hard links */
	uid_t     st_uid;         /* user ID of owner */
	gid_t     st_gid;         /* group ID of owner */
	dev_t     st_rdev;        /* device ID (if special file) */
	off_t     st_size;        /* total size, in bytes */
	blksize_t st_blksize;     /* blocksize for filesystem I/O */
	blkcnt_t  st_blocks;      /* number of 512B blocks allocated */

	/* Since Linux 2.6, the kernel supports nanosecond
	precision for the following timestamp fields.
	For the details before Linux 2.6, see NOTES. */
	
	struct timespec st_atim;  /* time of last access */
	struct timespec st_mtim;  /* time of last modification */
	struct timespec st_ctim;  /* time of last status change */
	#define st_atime st_atim.tv_sec      /* Backward compatibility */
	#define st_mtime st_mtim.tv_sec
	#define st_ctime st_ctim.tv_sec
} stat_info;


struct as requested from the stat syscall 

     struct stat {
               dev_t     st_dev;         /* ID of device containing file */
               ino_t     st_ino;         /* inode number */
               mode_t    st_mode;        /* protection */
               nlink_t   st_nlink;       /* number of hard links */
               uid_t     st_uid;         /* user ID of owner */
               gid_t     st_gid;         /* group ID of owner */
               dev_t     st_rdev;        /* device ID (if special file) */
               off_t     st_size;        /* total size, in bytes */
               blksize_t st_blksize;     /* blocksize for filesystem I/O */
               blkcnt_t  st_blocks;      /* number of 512B blocks allocated */

               /* Since Linux 2.6, the kernel supports nanosecond
                  precision for the following timestamp fields.
                  For the details before Linux 2.6, see NOTES. */

               struct timespec st_atim;  /* time of last access */
               struct timespec st_mtim;  /* time of last modification */
               struct timespec st_ctim;  /* time of last status change */

           #define st_atime st_atim.tv_sec      /* Backward compatibility */
           #define st_mtime st_mtim.tv_sec
           #define st_ctime st_ctim.tv_sec
           };

Heres how I want to invoke my syscall:

internal uintptr stat(char* pathname, stat_info *buf ){
	
	return (uintptr) syscall2(SYS_STAT,
				(void*)pathname,
  				(void*) buf);

	return NULL;
}

Here is how it will be used:

/***PUBLIC FUNCTIONS***/
internal uintptr getFilesize(char* path){
	stat_info tempstat;
	stat(path, tempstat);
  return stat.
}

 
the standard libs are there for a reason, though if your goal is to learn something about the underlying mechanisms go ahead just be willing to cheat
@zython holy mother of onebox...
 
I have already written a wrapper for puts, so it works and i nwated to branch out to something little more advanced
 
If you use the name stat then you will have conflicts whenever you include something that will happen to include the headers that define the original stat
 
9:30 AM
I only use one header file that I wrote myself so I think i should be fine
 
10:03 AM
Is there a good way to "hide" GUI code for a viewer's conveniance?
I made a 600-line file out of which only 100 lines max would be relevant for somebody who would want to look at a certain issue. The rest is just placement, sizes, colors, listeners, shapes etc.
I know someone might be tempted to say "the little square with the minus in it", but from what I gather, if it doesn't do that by default, people seem to be turned off from the code if they see all of those laurels wallowing out.
 
use #include to split the files
 
Ah, thank you. Never thought of that.
 
np :)
 
separating gui and functional code into separate files is commonplace
in larger applications that ends up falling under one of the MV* monikers
 
true
but if you can keep a secret, I'm doing it in Java, folks over in their part of the chat didn't seem too friendly when they weren't absent
 
10:12 AM
I've created gui tools in java and the first thing I do for that is seperate the model and gui in separate packages
also I make heavy use of the GroupLayout which I find the layout with the smallest code overhead to specify the layout with
 
I'm new to Java, I didn't have the necessary potty training before I got goaded into it and have about a week to finish this project. I'm just about done, except that now an ArrayList decided to do a lone-wolf and not misbehave.
No idea if it's some rule in Java I don't know about, and it's wreathed in code to the point that I can't remove enough to separate the issue without removing the necessary buttons that I use to check if it works or not. And obviously people take one look at it and run screaming into the hills.
 
unittests?
 
Never seen them before
googling though
 
though for a tight deadline it's not really viable to add comprehensive unittests
 
Somebody told me to use the debugger, I tried clicking 2-3 debugger "versions" in Eclipse, it did absolutely nothing. I should look into that when I wake up.
 
10:23 AM
you need to add breakpoints for it to do anything visible
you can then step through your code
though with gui code that's tricky because of the hidden event loop
 
ya, a week is not enough to grasp unittesting
 
@login_not_failed and to properly include them into the project
 
Hooray, the debugger is alive!
I ought to be able to fix it now eventually
 
10:50 AM
Thanks for the help, the debugger is finally working at least. I'm off to bed. Good night.
 
good night!
 
11:46 AM
hey I'm back with another question this time about casting ints to void pointers, gcc gives me some errors when previously everything worked just fine
gist: 78c661d6bb230509dbe67a659c35e403, 2017-03-14 11:45:10Z
Compiler Output:

In file included from jupiter.c:1:0:
echochamber.h: In function ‘read’:
echochamber.h:151:8: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
        (void*) fd,
        ^
echochamber.h: In function ‘open’:
echochamber.h:161:8: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
        (void*) flags);
        ^
echochamber.h: In function ‘close’:
echochamber.h:167:8: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
        (void*) fd);
        ^
echochamber.h: In function ‘fstat’:
echochamber.h:183:8: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
        (void*) fd,
        ^

Implementation:

/*attempts to read n bytes from a file descriptor into a buffer*/
internal uintptr read(int fd, void *buf, uintptr count){
	return (uintptr)syscall3(SYS_READ, /*SYS_READ = 0 defined above*/
							(void*) fd,
							(void*) buf,
							(void*) count);
}

/*open and or possbly create a file*/
/*returns a file descriptor*/
internal uintptr open(char* pathname, int flags){
	return (uintptr)syscall2(SYS_OPEN,
							(void*) pathname,
							(void*) flags);
}

/*invoke close syscall on an given file descriptor*/
internal uintptr close(int fd){
	return (uintptr)syscall1(SYS_CLOSE,
							(void*) fd);
}

/*invoke close syscall on an given file descriptor*/

internal uintptr stat(char* pathname, stat_info *buf ){
	
	return (uintptr)syscall2(SYS_STAT,
							(void*) pathname,
							(void*) buf);

}

/*invoke stat syscall but with filedescriptor*/
internal uintptr fstat(int fd, stat_info *buf){
	return (uintptr)syscall2(SYS_FSTAT,
							(void*) fd,
							(void*) buf);
}
 
cast first to intptr_t
 
12:02 PM
@zython don't, casing to void* should be avoided without a REALLY good reason
and in your case you should probably be either using intptr_t or uintptr_t instead
 
@zython You've made this warning an error, so you get an error instead of a warning. It's a warning because casting an arbitrary integer to a pointer makes no sense in general
(it's also "fun" when the int and the pointer have different sizes, as it is in your case.)
 
 
4 hours later…
nwp
4:03 PM
How do I access Traits::eof() here? Am I supposed to use std::char_traits<char>::eof() directly?
 
there seems to be traits_type in std::basic_istream, so I'm guessing if you want to be ultracorrect, then
decltype(std::cin)::int_type c = std::cin.get(); if(decltype(std::cin)::traits_type::eof()) do_stuff(); // FML
 
nwp
I get a std::istream &source, so apparently I have to do std::remove_reference<decltype(source)>::type::traits_type::eof(); //FML
 
hmmm, in that case you could std::istream::traits_type::eof()
 
nwp
but if I repeat a type monsters will eat me in my sleep
 
I think I have a proposal idea
 
nwp
4:15 PM
source.traits_type::eof() should totally compile
 
to allow something::member_type when typedef T& something; to be the same as T::member_type
 
 
2 hours later…
6:33 PM
struct A { void a () { } } ; class B : A { public : using A::a ; } ; B::a still has type void A::( ) am i right.? it is only introduce name of A::a in scope of B for lookup, yes.?
 
1 message moved from Lounge<C++>
 
* does it only introduce
 
@GreenTree it introduces a name, yes
it's also unnecessary since the name is accessible because A is a base of B, and a is a public member of A, and you don't do any name hiding
 
so B has no member 'a', right.?
 
what
it has a member a because you can access it if you do instance_of_b.a(), you can access it with &B::a, and so on
 
6:47 PM
in expression B().a(), 'a' is B::A::a that is A::a.
 
and that matters never
&B::a is how you can access that member
 
it matters at type deduction.
for example.
&B::a has type void ( A::* )( ).
 
you can check that yourself whether it is, actually
let me make an example
 
void f(U T::* a) wow. i never thought of such templating.
 
7:08 PM
@GreenTree I took it from std::mem_fn signature
 

« first day (246 days earlier)      last day (2613 days later) »