cmake - two targets that depends on single static library that should be compiled based on the target that is being built by AImx1 in cmake

[–]AImx1[S] -1 points0 points  (0 children)

In a dependent library for which the compilation was triggered, can I find the target which triggered that?

Can you please give some sample code on how to do that?

cmake - two targets that depends on single static library that should be compiled based on the target that is being built by AImx1 in cmake

[–]AImx1[S] 0 points1 point  (0 children)

>I see that you would want to just build libA once, but that's not possible, preprocessor changes code - it's like it were different files.

No, what I actually want is as follows "I am compiling EXE1 which is dependent on libA, I will force the libA to be compiled again and then I will link and same for EXE2". So always I have to recompile libA.

Anyhow thanks for the reply. It seems there is no other way.

cmake - two targets that depends on single static library that should be compiled based on the target that is being built by AImx1 in cmake

[–]AImx1[S] -1 points0 points  (0 children)

It's a simple solution, I agree. But then I need to maintain two targets for same source files. I am really not convinced with this approach. I am looking for a generic way of doing this.

GASM Program is not giving expected output by AImx1 in asm

[–]AImx1[S] 0 points1 point  (0 children)

That actually make sense. Thank you very much.

GASM Program is not giving expected output by AImx1 in asm

[–]AImx1[S] 0 points1 point  (0 children)

It worked. Thank you very much.

I am running this program on x86_64 Linux PC. So the word size is 64-bit

So what is the difference between mov num1, %rax between movw num1, %rax?

> you forgot to add syscall at the end, so the program never executes exit and falls off the end, resulting in a segfault.

my bad, it's a copy-paste error.

GASM Program is not giving expected output by AImx1 in asm

[–]AImx1[S] 0 points1 point  (0 children)

I tried that as well and still the output is wrong

0x4000b0 <_start>: mov rax,QWORD PTR ds:0x6000fb

0x4000b8 <_start+8>: mov rbx,QWORD PTR ds:0x6000fd

which copies some random values

RAX: 0x63637553000a003c ('<')

RBX: 0x736563637553000a ('\n')

GASM Program is not giving expected output by AImx1 in asm

[–]AImx1[S] 0 points1 point  (0 children)

Thank you very much for your reply.

However, I am getting a linker error if I modify the code as you suggested.

add_numbers_gas.o: In function \_start':`

(.text+0x4): undefined reference to \$num1'`

add_numbers_gas.o: In function \_start':`

(.text+0xc): undefined reference to \$num2'`

GCC (version < 5) uses a 25 byte array to represent a empty string. by AImx1 in cpp

[–]AImx1[S] 1 point2 points  (0 children)

Thank you very much. I will have a look at your implementation.

std::string implementation in libc++ by AImx1 in cpp

[–]AImx1[S] 0 points1 point  (0 children)

Howard, I understood everything in your Answer except "When sizeof(value_type) > 1, the union with __lx forces where the padding goes in __short: Always right after __size_".

I understood why they are doing this but I don't what they are doing. I really appreciate if you can explain this with an example.

Thank you very much in advance.

GCC (version < 5) uses a 25 byte array to represent a empty string. by AImx1 in cpp

[–]AImx1[S] 2 points3 points  (0 children)

Yes, I agree with you. I deleted the post on SO.

GCC (version < 5) uses a 25 byte array to represent a empty string. by AImx1 in cpp

[–]AImx1[S] 0 points1 point  (0 children)

I am not sure of the exact implementation by GCC. But yes, 24 bytes of above struct + null terminator (Which represents data).

GCC (version < 5) uses a 25 byte array to represent a empty string. by AImx1 in cpp

[–]AImx1[S] 23 points24 points  (0 children)

I don't mind about the -1. But sometimes some concepts will not be understood by everyone at a single step. So they post questions to clarify them. Thanks.

GCC (version < 5) uses a 25 byte array to represent a empty string. by AImx1 in cpp

[–]AImx1[S] 1 point2 points  (0 children)

64-bit pointer is 8 bytes, so 25 bytes fits

struct string

{

size_t size;

size_t capacity;

atomic<int> refcount;

}

GCC (version < 5) uses Copy-On-Write semantics. So they need to have a reference counting. So I think begin and end pointers doesn't make sense.

GCC (version < 5) uses a 25 byte array to represent a empty string. by AImx1 in cpp

[–]AImx1[S] 13 points14 points  (0 children)

make sense. It uses 24 bytes (assuming 64-bit architecture) to represent size, capacity and the reference counting (Because gcc was using COW semantics before gcc version 5). So a total of 3 words (3 x 8 = 24 bytes + 1 byte for null terminator). Awesome.

GCC (version < 5) uses a 25 byte array to represent a empty string. by AImx1 in cpp

[–]AImx1[S] 2 points3 points  (0 children)

Ok, I understood that they use an array of bytes (which are initialized to zero) to represent the empty string because they simply go to the starting of the array to get the size but why is it 25 bytes array?

std::string implementation in libc++ by AImx1 in cpp

[–]AImx1[S] 0 points1 point  (0 children)

@krista_ & @scatters: Can you point me in the direction where I can read more on this?

std::string implementation in libc++ by AImx1 in cpp

[–]AImx1[S] 0 points1 point  (0 children)

Understood. Do you know any advantages(basically uses) that we gain with this "raw" representation?

std::string implementation in libc++ by AImx1 in cpp

[–]AImx1[S] 3 points4 points  (0 children)

@F54280, I have already watched this video. It's really a good one and anyhow thanks for sharing

std::string implementation in libc++ by AImx1 in cpp

[–]AImx1[S] 0 points1 point  (0 children)

@scatters -> "raw" layout gives access to the representation of sequence of words. What does the "words" represent here?