When doing a std::cout << "Start" << std::endl; in vscode for Mac it always prints #"Start\r\n" to the debug console.
Is there a way to get rid of the #"\r\n" characters so that it would only print Start?
Best, Hu
You probably currently using llbd , try using externalConsole instead, by adding "externalConsole": true to launch.json, which will send the output to a separate terminal window.
Related
I'm facing the problem that my init.vim becomes not highlighted properly after the line with lua << EOF in NeoVim. The weird behaviour is 1) paired brackets are colored differently; 2) After lua << EOF a Lua context does begin, yet it doesn't seem to be ended after the next EOF, instead it continues being highlighted in a Lua syntax (all lines later on are affected). From the screenshot below you can see that the brackets in line 59 are displayed as white and red separately, and the Lua syntax stays after line 60.
The code itself is assumed as okay, since it can be sourced without any error or warning, and the editing functions normally. It should namly only be a problem with the highlighting.
Sadly I can't tell the context of this problem. I first noticed it today without doing anything special (e.g. installing a new plugin) and I'm not sure when it occured. I have no clue what is causing this, even after doing research on Google for more than one hour - I haven't seen any post describing a similar situation.
The problem remains with the default color scheme.
I was guessing the CoC extension coc-vimlsp could be relevant, but the problem remains after I disabled it. Otherwise I can't remember any NeoVim plugin that could have something to do with the highlighting.
EDIT: I noticed that the broken highlighting after EOF is relevant to the broken brackets. If I write no brackets in the heredoc block, the highlighting will work correctly. Looks like the Lua highlighting remains after the heredoc block because it thinks the brackets aren't closed properly. And this is only about round brackets (), other brackets like [] {} "" would cause no problem.
My init.vim:
" Indentation
set shiftwidth=4
set ai
set si
" Show line numbers
set nu
" Show command at the bottom right of the screen
set sc
" Limit the number of items shown in popup
set ph=20
" Set the minimal number of lines below the cursor
set so=15
" Disable auto comment insertion
au Filetype * setlocal fo-=c fo-=o fo-=r
" vim-plug config
call plug#begin()
" Themes
Plug 'catppuccin/nvim', {'as': 'catppuccin'}
Plug 'tiagovla/tokyodark.nvim'
" Icon support
Plug 'ryanoasis/vim-devicons'
" Statusbar
Plug 'nvim-lualine/lualine.nvim'
" Fish support
Plug 'dag/vim-fish'
" Makrdown support
Plug 'preservim/vim-markdown'
" Markdown preview
Plug 'iamcco/markdown-preview.nvim', { 'for': ['markdown', 'vim-plug'] }
" TeX support
Plug 'lervag/vimtex'
" Auto close XML-like tags
Plug 'alvan/vim-closetag'
" Auto close brackets
Plug 'jiangmiao/auto-pairs'
" CoC completion engine
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
call plug#end()
" catppuccin config
let g:catppuccin_flavour = "mocha" " latte, frappe, macchiato, mocha
lua << EOF
require("catppuccin").setup()
EOF
" Set colorscheme
colorscheme catppuccin
" lualine config
lua << EOF
require('lualine').setup({
options = {
theme = "horizon"
}
})
EOF
" vim-markdown config
let g:tex_conceal = ""
let g:vim_markdown_math = 1
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_new_list_item_indent = 0
" Enable vimtex for Markdown files
" Not ideal, since this enables ALL features of vimtex
au Filetype md,markdown call vimtex#init()
" VimTeX config
let g:vimtex_compiler_latexmk = {'continuous': 0}
" CoC config
exe 'so ~/.config/nvim/coc_config.vim'
Operating system: MacOS Monterey 12.4
Output of nvim -v:
NVIM v0.8.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew#Monterey
Features: +acl +iconv +tui
See ...
The issue raised in both of Neovim and Vim repository.
Neovim side: https://github.com/neovim/neovim/issues/20456
Vim side: https://github.com/vim/vim/issues/11277
Workaround from the comment: reverting to v0.7.2 lua syntax:
curl -sS https://raw.githubusercontent.com/neovim/neovim/v0.7.2/runtime/syntax/lua.vim > $VIMRUNTIME/syntax/lua.vim
I have encountered a very strange issue with printing to console using std::cout in a c++11 application under CentOS.
printf("Before...\n"); // This gets printed with no issue
std::cout << "This won't be printed to console\n" << std::flush; // This won't get printed
std::cout.flush();
printf("After...\n"); // This gets printed with no issue
The output in the console is:
Before...
After...
The cout message for some reason is not printed. There is no stdout redirection in my code. I purposely redirected cout to a file but the issue was not solved. I am confused as to where to track down the issue.
What would prevent cout from printing? In what potential scenarios, cout stops functioning? What could be the issue?
Problem:
CLion doesn't output any console output for debugging purposes.
I'm using CLion with the MingW compiler and cmake. No matter whether I use:
std::cout << "Testing" << std::endl;
Or:
printf("Testing");
I don't see any console output.
Attempts at Resolution:
1:
I've checked "Run", "Debug", "Terminal" and "Cmake". I've attempted to edit my configurations but "Debug" doesn't show up.
2:
Next, I went to Settings->Build,Execution,Deployment->CMake to edit the Generation types. I added Debug and RelWithDebInfo and still to no avail.
3:
I also attempted to add "-Debug" to Cmake, but I still have no output.
4:
The closest thing I've received for debugging is using GDB to view variable values at break points. This only works in the "RelWithDebInfo" generation.
Solution:
I ended up figuring out what the problem was.
I'm developing a Qt GUI application within CLion on Windows. You have to specify a console for console output to print onto.
Call this Console() function early in your main for a console prompt to open up. Now, whenever you run
QDebug() << <string>;
or
std::cout << <string> std::endl;
You'll see your debugging statements. Hope this helps somebody else out there with the same problem.
Code:
void Console()
{
AllocConsole();
FILE *pFileCon = NULL;
pFileCon = freopen("CONOUT$", "w", stdout);
COORD coordInfo;
coordInfo.X = 130;
coordInfo.Y = 9000;
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coordInfo);
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE),ENABLE_QUICK_EDIT_MODE| ENABLE_EXTENDED_FLAGS);
}
Source:
I found a solution here:
[0] Console output in a Qt GUI app?
There's a simpler solution that doesn't require adding any code. Simply add the following environment variable in your debug configuration:
QT_ASSUME_STDERR_HAS_CONSOLE=1
With this, CLion shows QDebug and QML's console.*() when started with a debugger.
Has anyone tried to execute multiple commands in a JUNOS router using ruby with the net/ssh and net/ssh/telnet gems where you have to go into configure mode? It never wants to accept the configure commands and I don't know why.
Here is my code:
def exec_router(host_type, commands)
puts "commands: #{commands}"
output = ""
ssh = Net::SSH.start(HOST_MAP[host_type], QA_USER, :password => QA_USER_PASSWORD)
t = Net::SSH::Telnet.new("Session" => ssh, "Prompt" => /.+#.+>/, "Output_log" => "/tmp/test.outputi")
commands.each { |command| output << t.cmd(command) }
puts output
t.close
ssh.close
end
And here is the output that it produces:
commands: ["configure", "show policy-options prefix-list greautomation-676872"]
configure
^
unknown command.
{master:member0-re0}
qa#c1.lab5> show policy-options
^
syntax error, expecting <command>.
qa#c1.lab5> show policy-optionsprefix-list
^
syntax error, expecting .
qa#c1.lab5> show policy-optionsprefix-listgreautomation-676872
^
syntax error, expecting .
I know my ssh/telnet stuff is working because I can replace the block that iterates through the command array with t.cmd('?') and I get the expected output with no errors.
My Junos version is 15.1F6-S3.8 and I am using ruby 2.3.0.
Thanks in advance
Craig
Have you checked https://github.com/Juniper/net-netconf? It is a Ruby Gem for doing NETCONF based interactions with Junos devices.
You should use RubyEZ.
Refer: https://github.com/Juniper/ruby-junos-ez-stdlib
to get the configuration of the device, we have get-configuration rpc.
data = ndev.rpc.get_configuration # Junos specific RPC
puts "Showing 'policy-options' hierarchy ..."
puts cfgall.xpath('policy-options')
To call operational rpc (for ex "show chassis hardware" corresponds to get-chassis-inventory rpc), hence
data = ndev.rpc.get_chassis_inventory
Although I would recommend you to use RubyEZ libraries, your problem is related to the fact that you are trying to execute a configuration syntax command in the operational mode.
Here is your problem:
commands: ["configure", "show policy-options prefix-list greautomation-676872"]
Make the following changes:
remove the "configure" command
replace "show policy-options prefix-list greautomation-676872" with "show configuration policy-options prefix-list greautomation-676872"
This should solve your problem.
I highly recommend you to look into RubyEZ libraries from Juniper.
I am trying to debug a C++ program using GDB. I have set 15 breakpoints. Most of the breakpoints are in different files. After the first 5 breakpoints, it became difficult to remember what line of code any given breakpoint refers to.
I struggle quite a bit simply trying to recall what a given breakpoint refers to. I find this quite distracting. I was wondering if there is a way to tell gdb to display code around a certain breakpoint.
Something like this - $(gdb) code 3 shows 30 lines of code around breakpoint 3. Is this possible today. Could you please show me how?
I run gdb in tui mode, and I also keep emacs open to edit my source files.
You can use gdb within emacs.
In emacs, type M-x gdb, after entering the name of the executable, type M-x gdb-many-windows. It brings up an IDE-like interface, with access to debugger, locals, source, input/output, stack frame and breakpoints.
You can find a reference and snapshot here.
I don't think you can do it exactly like this in gdb as such, but it can be scripted in gdb python.
This crude script should help:
import gdb
class Listbreak (gdb.Command):
""" listbreak n Lists code around breakpoint """
def __init__ (self):
super(Listbreak, self).__init__ ("listbreak", gdb.COMMAND_DATA)
def invoke (self, arg, from_tty):
printed = 0
for bp in gdb.breakpoints():
if bp.number == int(arg[0]):
printed = 1
print ("Code around breakpoint " + arg[0] + " (" + bp.location + "):")
gdb.execute("list " + bp.location)
if printed == 0:
print ("No such breakpoint")
Listbreak()
Copy this to listbreak.py, source it in gdb (source listbreak.py), then use it like this:
listbreak 2