Chat Boss
Kiani sent a huge message, it has been re-uploaded as a quote Hi everyone. I'm attepmting to debug my application using lldb. But unfortunately I'm getting the error below (Wanted to attach the image but group settings doesn't allow it). Seems like std::string is not being recognized by the lldb but on the other hand image lookup -t std::string in lldb is returning type data. Any solutions? * thread #2, name = 'DrogonIoLoop', stop reason = breakpoint 1.1 frame #0: 0x00005555555ad0f2 arc`controllers::MyController::hello(this=0x0000555555619fd0, req=std::__shared_ptr<drogon::HttpRequest, __gnu_cxx::_S_atomic>::element_type @ 0x00007ffff0003cf0, callback=0x00007ffff61f7cd0) at MyController.cpp:16:32 13 HttpResponsePtr resp = HttpResponse::newHttpResponse(); 14 resp->setBody("Called!"); 15 std::string tok = "token"; -> 16 std::string token = req->getHeader(tok); 17 auto getenv = std::abs(-1); 18 callback(resp); 19 } (lldb) p req->getHeader(tok) error: arc 0x0008f9c7: DW_TAG_member '_M_local_buf' refers to type 0x00000000000a552c which extends beyond the bounds of 0x0008f9bd error: arc 0x000aaf36: DW_TAG_member '__u6_addr8' refers to type 0x00000000000aaf69 which extends beyond the bounds of 0x000aaf2c error: arc 0x000aaf42: DW_TAG_member '__u6_addr16' refers to type 0x00000000000aaf79 which extends beyond the bounds of 0x000aaf2c error: arc 0x000aaf4e: DW_TAG_member '__u6_addr32' refers to type 0x00000000000aaf89 which extends beyond the bounds of 0x000aaf2c error: Couldn't look up symbols: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) Hint: The expression tried to call a function that is not present in the target, perhaps because it was optimized out by the compiler. (lldb) std::string j = "123" error: 'std' is not a valid command. (lldb) p std::String j="123" error: <user expression 1>:1:6: no type named 'String' in namespace 'std' 1 | std::String j="123" | ~~~~~^ (lldb) p std::string j ="123" error: <user expression 2>:1:13: no viable conversion from 'const char[4]' to 'std::string' (aka 'std::basic_string<char>') 1 | std::string j ="123" | ^ ~~~~~ note: candidate constructor not viable: no known conversion from 'const char[4]' to 'std::nullptr_t' for 1st argument note: candidate constructor not viable: no known conversion from 'const char[4]' to 'std::basic_string<char> &&' for 1st argument note: candidate constructor not viable: no known conversion from 'const char[4]' to 'const std::basic_string<char> &' for 1st argument note: explicit constructor is not a candidate (lldb)
klimi
it seems to me that there is std::String vs std::string problem (haven't looked in detail tho)
Kiani
it seems to me that there is std::String vs std::string problem (haven't looked in detail tho)
But the problem is that the exact code is written and compile into the code and its working in the line 16 of the code. I'm not defining anything new as std::String but woudln't it be also problematic inside the code itself?
klimi
hard to say without looking at the code
Chat Boss
hard to say without looking at the code
Kiani sent a code, it has been re-uploaded as a quote It is a minial project. Here's the method that is being called by the Drogon: #include "MyController.h" #include <memory> namespace controllers { void MyController::hello(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback) { std::cout << "Called!"; HttpResponsePtr resp = HttpResponse::newHttpResponse(); resp->setBody("Called!"); std::string tok = "token"; std::string token = req->getHeader(tok); callback(resp); } } Also MyController.h: #pragma once #ifndef MYCONTROLLER_H #define MYCONTROLLER_H #include <drogon/HttpController.h> #include <drogon/HttpSimpleController.h> using namespace drogon; namespace controllers { class MyController : public drogon::HttpController<MyController, false> { public: static std::string message() { std::string message = "hello"; std::cout << message << std::endl; return message; } public: // GET /api/hello void hello(const drogon::HttpRequestPtr &req, std::function<void(const drogon::HttpResponsePtr &)> &&callback); // // POST /api/data // void postData(const drogon::HttpRequestPtr &req, // std::function<void(const drogon::HttpResponsePtr &)> &&callback); // // // GET /api/users/{id} (Path parameters) // void getUser(const drogon::HttpRequestPtr &req, std::function<void(const drogon::HttpResponsePtr &)> &&callback, // int id); // Note the 'int id' // // // GET /api/query?name=John&age=30 (Query parameters) // void queryParams(const drogon::HttpRequestPtr &req, // std::function<void(const drogon::HttpResponsePtr &)> &&callback); METHOD_LIST_BEGIN METHOD_ADD(MyController::hello, "/hello", Get); // PATH_ADD("/api/data", Post, postData); // PATH_ADD("/api/users/{id}", Get, getUser); // Path parameter // PATH_ADD("/api/query", Get, queryParams); // Query parameters METHOD_LIST_END }; } // controllers #endif //MYCONTROLLER_H
SAMIR
Hii guys
SAMIR
How are you
Muhammed
Fine and you?
GPU Governor
i am trying to write a small memory safe C++ hobby compiler, does anyone has suggestions and feed back on how to solve memory issues Without Borrow Checking, Reference Counting, or Tracing Garbage Collection
GPU Governor
At compile time
Ludovic 'Archivist'
Ludovic 'Archivist'
But then you strayed from C++
Ziky
I would not mind having free good static analysis
Ludovic 'Archivist'
This is cool
You could also add a safe and unsafe attribute, make manipulating a raw pointer or C array in a safe function illegal (be careful, because this is a raw pointer you may need to add an extra check on this) Then a properly labeled standard library would keep you safe from, specifically, memory unsafety.
Ludovic 'Archivist'
You will need to make your abstractions in the standard library enforce this, and may need a unsafe_only attribute to tag things that can only be called in an unsafe context like the std::vector::operator[]
GPU Governor
You will need to make your abstractions in the standard library enforce this, and may need a unsafe_only attribute to tag things that can only be called in an unsafe context like the std::vector::operator[]
Also what do you think of this; i am considering writing a transpiler instead of a compiler that transpiler source code to c++ and then do all the errors and memory safety at transpiler time before the output will be compiled by standard cpp compilers (gcc, clang); just like the way kotlin and typescript work
GPU Governor
That way i might reduce the work time it will take to write a full compiler
Rose
User Jetha has 1/2 warnings; be careful! Reason: English only
h
Hi, i want to generate all words with 4 letter, How can i do?
klimi
Hi, i want to generate all words with 4 letter, How can i do?
You can write a program that will do it for you or you can do it by hand
h
You can write a program that will do it for you or you can do it by hand
aaaa,aaab,aaac,aaad,aaae,.......................zzzz
h
all words are 26*26*26*26
h
all words are 456,976
Ziky
i want a program on C++
do you know that each letter is in fact a number (ASCII codes)
h
if you can, please send a program
Chat Boss
h ghaderi sent a code, it has been re-uploaded as a quote #include "stdafx.h" #include <ctype.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> int menu(); int entertext(); void four_words(); int main() { int words; int i; while(1) { i=menu(); switch (i) { case 1:entertext(); break; case 2: four_words(); break; case 3:exit(0); default: printf("\nInvalid choice\n\n"); break; } } return 0; }
h
i can not send here my program
h
send as a file
h
thanks
SAMIR
Guys i have all programming notes
SAMIR
ok
Okay
Ziky
yes
what about this approach? I am not sure if the mats is correct but you see the point. char word[] = { ('a'+i/(26*26*26)) , ('a'+i/(26*26 ))%(26 ), ('a'+i/(26 ))%(26*26 ), ('a'+i )%(26*26*26), '\0' };
Ziky
no it is wrong :D
consteval
i/17576, i/676%26, i/26%26, i%26
Ziky
i/17576, i/676%26, i/26%26, i%26
this is probably correct
Ludovic 'Archivist'
That way i might reduce the work time it will take to write a full compiler
You may be able to use treesitter as a starting point
h
this is probably correct
import string mylist = [] mystring = string.ascii_lowercase for a in mystring: for b in mystring: for c in mystring: for d in mystring: mylist.append(a + b + c + b) print(mylist) print("aaaa" in mylist) print("zzzz" in mylist) print("Size of list =", len(mylist)) # 456976 4-letter words... using just lowercase. # also...have a look at: mylist2 = ["".join(x) for x in itertools.product(mystring, repeat=4)] print(len(mylist2)) print("aaaa" in mylist2) print("zzzz" in mylist2) edit:- you can also do:- mylist = [a+b+c+d for a in mystring for b in mystring for c in mystring for d in mystring]
h
yes, is correct Algorithm?
h
can you write for 2 words?
h
2 letters
h
26*26 = words
h
its for generating pass for 4 letters
Ziky
not correct
It is correct, i tried it
h
i have to check it again
h
if its correct, can you send the text file for me? send private, thanks
h
output text file
Ziky
THe algoritm is correct
h
are you sure?
Ziky
are you sure?
yep c unsigned i=26*26*26; char word [] = { 'a'+i/17576, 'a'+i/676%26, 'a'+i/26%26, 'a'+i%26, 0 }; printf("%s", word);
h
i=26*26*26; its for 3 letters!!
Ziky
it will change the first letter in array to b
Ziky
i=26*26*26*2 will change it to caaa
h
can you send out put file?
Ziky
all I have is this https://onlinegdb.com/GAMEQh9jr put it in the loop by yourself
h
caaa is output
h
i want, aaaa, aaab, aaac,..................................zzzz
Ziky
so change it
Chat Boss
Havoc sent a code, it has been re-uploaded as a quote KeyChain* keyChainMalloc(DataType type, int units, KeyChain* origin){ if (origin == NULL || units <= 0) { return NULL; } KeyChain* tail = origin; while (tail->next != NULL) { tail = tail->next; } for(int i = 1; i <= units; i++){ KeyChain* adjacent_point = (KeyChain*)malloc(sizeof(KeyChain)); adjacent_point->units = units; adjacent_point->index = tail->index + 1; adjacent_point->type = type; adjacent_point->key = NULL; adjacent_point->next = NULL; tail->next = adjacent_point; tail = adjacent_point; } return origin; } Am I correctly adding nodes to a linked list from the tail, or am I messing something up
Havoc
typedef struct KeyChain{ Key* key; DataType type; int units; int index; struct KeyChain* next; } KeyChain; this is the struct if anyone wants
Ziky
@admin
Rose
Reported Alvin Andrê [1431731578] to admins.​​​​​​​​​​
Spam
has anyone done scraping using c++?
klimi
has anyone done scraping using c++?
yes, people have done scraping using c++ (although why you would do such thing is unknown :) )
Don
has anyone done scraping using c++?
I have done it. how can I help you?
Aniverse
Guys how do you solve these string questions? Like what is your approach in doing questions of strings. Some questions ask to convert numbers into text , these type of questions!
Spam
I have done it. how can I help you?
i have experience doing it through python, can you please share a snippet i'll work my way around
Aniverse
Are you asking how to convert a numerical variable into ascii string representation in decimal?
Yeah like we are given 1321 we've to return one thousand three hundred twenty one and vice versa
klimi
Yeah like we are given 1321 we've to return one thousand three hundred twenty one and vice versa
you usually just convert it to ascii then, if you want in decimal, then you do it for each 10's and add '0'.
klimi
vulnerability assessments XD
No idea what you are talking about.